Hi,
I want to create an application which works when system is shutting down. So, my question is that is it right way to implement Environment.HasShutdownStarted property for my propose..?
SystemEvents.SessionEnding +=
new SessionEndingEventHandler(SystemEvents_SessionEnding);
void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
{
if (Environment.HasShutdownStarted)
{
//…………………………
}
else
{
//………………
}
}
VulpesPosted Aug 2, 2011, 4:27 AM
Thomas MapotherPosted Aug 2, 2011, 11:46 PM
Sam HobbsPosted Aug 2, 2011, 7:45 PM
Note that your question is not a C# language question. I am not sure what forum would be most appropriate but you really should specify what type of program this is for. Assuming this is a Windows Forms application, you can override the Form.WndProc Method. In a console application you can probably use the IMessageFilter Interface but you will need to do something, such as create a form, to create a message loop.
Okay?
Zoran HorvatPosted Aug 2, 2011, 3:54 AM
You should test your application very carefully because applications probably often see ghosts in MS operating systems when system is shutting down.
Zoran