Have a problem.
Here is what happens in the background (I beleive). The user attempts to restart the computer. First the Form1_Closing ev is called. It cancels the close event, making windows stop shutting down. Because of that, the UserShutdown ev is not called at all.
How can I tell from the Closing ev that the user is trying to shut down? Is there a way I can wait on that event? Or maybe there is another way? What do you think?
C#:
private void UserShutdown(object sender, SessionEndingEventArgs e)
{
MessageBox.Show("exit");
Application.Exit();
}
//-------------------------------
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel=true;
this.Visible=false;
MessageBox.Show("closed");
}
How can I tell from the Closing ev that the user is trying to shut down? Is there a way I can wait on that event? Or maybe there is another way? What do you think?