• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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