P
Paul Steele
Some time ago I tracked down the code for detecting the shutdown event
within a C# program. I tested it, it worked, and I moved on. However, I just
discovered that the code is no longer working, and I'm baffled. I've done
some more Google searches and have come up with the same thing. A portion of
the code is below. I call the HookSessionEnding routine in the Load event of
the main form, but the shutdown event code never fires. I'm baffled.
using Microsoft.Win32;
private void HookSessionEnding()
{
SystemEvents.SessionEnding += new
SessionEndingEventHandler(this.OnSessionEnding);
}
private void OnSessionEnding(object sender, SessionEndingEventArgs e )
{
MessageBox.Show("Shutting down");
}
within a C# program. I tested it, it worked, and I moved on. However, I just
discovered that the code is no longer working, and I'm baffled. I've done
some more Google searches and have come up with the same thing. A portion of
the code is below. I call the HookSessionEnding routine in the Load event of
the main form, but the shutdown event code never fires. I'm baffled.
using Microsoft.Win32;
private void HookSessionEnding()
{
SystemEvents.SessionEnding += new
SessionEndingEventHandler(this.OnSessionEnding);
}
private void OnSessionEnding(object sender, SessionEndingEventArgs e )
{
MessageBox.Show("Shutting down");
}