Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows service - best practice for OnStart
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01051752
Message ID:
01052503
Views:
8
>What's the best practice for getting things going in a Windows service?. If I understand right, OnStart needs to comlete within 30 seconds, and you're also supposed to put your code there that makes the service useful.
>
>In the couple services I have, I've launched a thread from OnStart to start the never-ending stuff my code needs to do. Is this considered ok, or is there a better method?
>
>Thanks,
>Mike

You'll also want to wrap any calls in OnStart in a try/catch. If any of your code in the other thread throws an exception, you want to make sure your service continues to run and can recover or log the problem. Otherwise you'll find your service seems to stop every once in a while and it can be hard to figure out why.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform