How can we keep calling OnStart() in Started condition of Windows Service in C#
-
Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......
-
Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......
Create a global Timer instance like System.Timers.Timer or System.Threading.Timer in your service class that you enable and start in your OnStart() event. Then every time the timer event fires you can perform your logic you need to. And you can set it to fire as often as you like. Hope this helps.
-
Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......
Hi, You could place a timer control on your service and do your programming logic in timer elapse event. Set the timer elapse time say 10 seconds or what ever you want and launch your exe. cheers
-
Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......
Use a BackgroundWorker object. Timers are okay, but they send the lowest priority message Windows has, and it's not guaranteed to be handled in a busy system. So, to avoid the issue, use a BackgroundWorker.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001