FileSystemWatcher on startup?

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi. I am supporting a Windows service that uses FileSystemWatcher to
monitor an inbound directory for new files. If the service is shutdown
and files are dropped to the inbound directory, those files are not
picked up by FileSystemWatcher at service startup.

This is a rare circumstance where the service will be down, but it does
happen occasionally during maintenance windows.

The solution to this problem that is in the code now is that a Timer
has been introduced to watch the directory as well. That forced the
addition of some thread mgmt (lock{}) so that both the timer and the
FileSystemWatcher (on separate threads) don't process the same file.

Is there a way to get FileSystemWatcher to pick files up at startup?
I'd love to bag the Timer (it's always a special feeling ditching
code). :-)

Thanks,
Jeff
 
I had the same problem and my solution was to create a separate thread class
that my FSW and timer would feed files to. My class handles all the locking
and tracking of the identified files that need to be processed. If you
want, I can upload the VB 2005 code I use to do this. It's been running
under beta 2 for several months without any crashes or other problems.

Mike Ober.
 
Thanks for the note (and the offer) Mike. Nah, that's ok. It sounds
like it's about a wash with the solution we have in place (lock{}'ing
the processing method). Not sure it's worth me changing at this point.

Thanks again.
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top