Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows service - best practice for OnStart
Message
From
21/09/2005 15:56:50
Keith Payne
Technical Marketing Solutions
Florida, United States
 
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:
01051766
Views:
6
Mike,

Does the service need the "never-ending stuff" to intialize? Usually a service will set some initial properties, set up it's event log, and then sit and wait for an event.

It might be better to move the code out of the OnStart and instead start a thread that will trigger the service's function that contains the code. This could make it a lot easier to troubleshoot any problems that occur. You won't have to attach the debugger to a separate thread and the service can make entries into the event log when exceptions occur.

>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform