Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OnShutdown event in a Windows Service
Message
De
28/03/2014 03:46:46
 
 
À
27/03/2014 16:06:17
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01597504
Message ID:
01597526
Vues:
35
.NET has the SystemEvents.SessionEnding event : http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.sessionending(v=vs.110).aspx

It uses the message pump so it's not quite so simple to use in a windows service. MS suggest either using the local system account and setting 'Allow service to interact with desktop' or using a hidden form. See second example here : http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents(v=vs.110).aspx




>Has anyone made use of the OnShutdown event in a Windows Service? I see there is an event for that. So, we can plug code in there. However, this is for someone who would reboot the server. While the service is in a loop, I would like to block the shutdown and send a message to the user, such as we see on regular services where we have to wait until the process finishes its loop, current process or else, and then that warning goes off by itself. There is still the possibility that the user can force an immediate reboot without waiting. But, that is ok. This is just how Windows is. At least, I need to send something to the user so he would know to wait a few seconds for an ongoing process to complete.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform