thread in web app?

My Web application needs to constantly poll a directory on its sever for new files.
If the files contents haven’t changed for like 5 seconds it processes that file, then deletes it and goes on to the next file…
This loop goes on and on for ever in the background.

Should this be setup as a thread in the main application or should I have two applications running on the server, one to serve the user and another to polls and process this directory?

Surely a Timer is what you need.

I believe threading was fixed in this release for web applications. Although I would recommend separating your web-app from the file processing you wish to do and make a dedicated console based service…otherwise your webapp will consume your CPU…even with threading or timers…but brian is right…you will want to thread the processing and use a timer to loop the process at regular intervals…