• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Don't trap form closing event when computer shutting down

Hello,

I trap my main form from closing and give the user an options box to remind them that the services of the app will no longer work if they close vs. minimize the application (which goes to the systray).  However, when they shut down the computer my application still gives the warning and demands a response before the computer shuts off.  Is there a way to ignore the formclosing event IF the computer is closing the app during the shut down process?


VS 2010
.Net
Windows Forms
Windows 7 64, 32 & Win XP 32

Thanks for any thoughts
Zip
0
zipnotic
Asked:
zipnotic
  • 2
1 Solution
 
David L. HansenProgrammer AnalystCommented:
In your FormClosing event do this check:


    If e.CloseReason <> CloseReason.WindowsShutDown Then
        'give warning
    Else
        'don't warn
    End If
End Sub
0
 
zipnoticAuthor Commented:
Thanks!
0
 
David L. HansenProgrammer AnalystCommented:
sure.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now