2

Is there a feasible way to allow an instance of the FileSystemWatcher class to continue to run, even when the application pool shuts down due to inactivity, say overnight? The .NET default is 20 minutes of inactivity.

Ideally, I'd like for the FileSystemWatcher to always listen for file system changes, as the potential for files being transferred in/out of our file store, or modified, is there even overnight when our application pool is shut down due to inactivity.

Thanks.

EDIT: For more context, my original thought was to implement an instance of FileSystemWatcher within my C# web application that will be deployed and run by IIS. It's functionality will be fairly standard: listening for file creation, file deletion, and file renames.

Peter Ritchie
  • 35,463
  • 9
  • 80
  • 98
Matt
  • 23,363
  • 39
  • 111
  • 152
  • 3
    App Pool and FileSystemWatcher don't have anything to do with eachother. I suppose to adequately answer your question, the readers will have to know how you are using FileSystemWatcher. For example, if you are using FileSystemWatcher within a windows service, then I don't believe you have an issue - perhaps THAT answers your question. – Jeremy Sep 24 '12 at 17:40
  • The best solution is probably to create a windows service that starts a FileSystemWatcher and stores the changes into a some kind of a database. – Casperah Sep 24 '12 at 17:45
  • What "application pool" are you talking about? – Peter Ritchie Sep 24 '12 at 18:09
  • @Peter, IIS Application Pools, which control one or more websites in IIS. – Matt Sep 25 '12 at 13:01
  • @MegaMatt I know what ISS application pools are; but they're not the only application pools... – Peter Ritchie Sep 25 '12 at 13:03
  • Just answering your question, man – Matt Sep 25 '12 at 19:37

1 Answers1

4

IIS is really intended to handle incoming requests, and is not suited towards this type of activity.

If you want the FileSystemWatcher to always work, it would be better to move your code into a standard Windows Service. This will cause it to execute upon the system startup, and continue running, even if IIS is not running or is idle.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373