Reputation: 20674
I have built a program with C# and the program keeps running on system tray near the windows clock. When I try to shut down windows, the program is still running and shutting down windows get stuck.
This is not a program with Windows 7.So my question here is how to add 'something magic' to allow windows to shut down?
Upvotes: 0
Views: 175
Reputation: 404
In your form closing event you have to catch windows closing message.FormClosingEventArgs has a property named CloseReason. An example is shown below
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.WindowsShutDown)
{
e.Cancel = false;// or Application.Exit();
}
}
Upvotes: 1