jeffreyjseaman
asked on
C# Windows Service
I have C# Windows Service written and it works fine. When I start the services it executes the commands and does what it needs to do and then stop.
What I need it to do is the following;
1. Listen to when a new message is available via IBM MQ and then start the services automatically.
How can I accomplish this? Should my service not stop and run constantly v/s stopping and then starting back up. Any suggestions, code examples etc; would be greatly appreciated.
Thanks
What I need it to do is the following;
1. Listen to when a new message is available via IBM MQ and then start the services automatically.
How can I accomplish this? Should my service not stop and run constantly v/s stopping and then starting back up. Any suggestions, code examples etc; would be greatly appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If it's in a loop yes.
essentially you keep in "running" the entire time. After the 500 seconds (note sleep is in MS, so it would be 500,000 you would pass in the value for 500 seconds), it would wake itself up and continue to run. You hold onto any memory you used, but no CPU cycles are wasted during the sleep time.
Note you should also handle the stop event.
http://code.msdn.microsoft.com/windowsdesktop/CSWindowsService-9f2f568e
essentially you keep in "running" the entire time. After the 500 seconds (note sleep is in MS, so it would be 500,000 you would pass in the value for 500 seconds), it would wake itself up and continue to run. You hold onto any memory you used, but no CPU cycles are wasted during the sleep time.
Note you should also handle the stop event.
http://code.msdn.microsoft.com/windowsdesktop/CSWindowsService-9f2f568e
ASKER
Thank You. I will try this out. Appreciate your help.
ASKER
What I wanted.. Thank You...
ASKER
So if I do the Thread.CurrentThread.Sleep
Will the Service automatically start back up after the 500 seconds or whatever the set time was?
Thanks
Jeff