Reputation: 21
I want to stop my C# application from running after the user has clicked shut down of computer so any idea how to do it?
Upvotes: 1
Views: 992
Reputation: 11844
you can use CloseReason.WindowsShutDown for this purpose inside the form closing event.
if (e.CloseReason != CloseReason.WindowsShutDown)
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
Upvotes: 8