Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Windows service - best practice for OnStart
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01051752
Message ID:
01052503
Vues:
10
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform