HI Guys,
I have created a windows service which spawns three threads.The first thread wakes up every 15 sec, the second thread wakes up every min. and the third thread once in a day.
My Code looks something like this:
var timer1 = new Timer();
timer1.Elapsed += ProcessTimerEvent1;
timer1.Interval = 60000;
timer1.Start();
var timer2 = new Timer();
timer2.Elapsed += ProcessTimerEvent2;
timer2.Interval = 15000;
timer2.Start();
var timer3 = new Timer();
timer3.Elapsed += ProcessTimerEvent3;
timer3.Interval = 86400000;
timer3.Start();
From my event logs I can see that it is saying .NET Runtime 2.0 Error Reporting EVENTID:5000.
I looked through the net and it says invalid operationexception.
DO you guys think whether this stopping of service has to do anything with threads.
And the other silly question is am I spawning 3 new threads everytime or the same threads gets up evey 15 sec or 1 min.
Probably one of your threads is throwing an unhandled exception. This will let your process die immediately. Make sure that you handle any exception inside your threads at some point by wrapping the code inside the thread into try-catch-blocks (and don’t forget to log properly so that you can be aware of the things that go wrong).