views:

880

answers:

5

Hi,

Anyone see any potential problems adding a FileSystemWatcher and a Timer into my derived ServiceBase class??

Malcolm

A: 

We have FileSystemWatchers and timers in our derived classes. What problems are you anticipating.

Preet Sangha
+1  A: 

No. There should be no problems in using these classes in a Windows Service. Both of these classes (not sure which "Timer" class you're using) should work fine in a Service environment.

If you're running into problems, specifying those might help us figure out how to help...

Reed Copsey
+2  A: 

Just be sure to wrap the events for each in a try-catch as they will run on threads from the Thread Pool. If there is an exception during the processing of that event your service may stop running unexpectedly. You should also keep the processing in the FileSystemWatcher Event to a minimum, for instance, just add the file path to a queue and then have one of your timers or Background Worker process the queue.

CodeMonkeyKing
A: 

I don't think so. I have used System.Threading.Timer in Windows service & its not working. After 2-3 times the code the does not work thought the service is in the running state. Still trying to figure out the solution to the problem. If any one knows the solution, do let me know. It's driving me crazy :(

A: 

http://support.microsoft.com/kb/842793

check that article.