Computer requires 2 shutdown requests

maxmanzero

Member
Joined
Sep 29, 2004
Messages
12
Programming Experience
Beginner
Below is the code I am using in the overridden form's wndProc to capture a QueryEndSession message.

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Select Case m.Msg

Case 17

KillWatchDog()
Application.Exit()
End Select

MyBase.WndProc(m)

End Sub

I am capturing this message so that I can disable a hardware timer my program is communicating with. The problem is when I tell Windows to shutdown my program disables the timer and closes just like it should, but windows doesn't shutdown. I have to select Shutdown or Restart again for the message to go through. Am I missing a pass through or something.

VS.NET 2003, Windows 2kPro
 
Thanks for the help

I have tried putting the MyBase call in several places, but finally I figured out a solution. Instead of trying to process the QueryEndSession message in the WndProc for the form, I set a global integer that tells the form_closing event that the reason it is closing is because of a windows shutdown. This has fixed the problem completly. I think that the reason it wasn't working was the KillWatchDog() and Application.Exit() calls were eating the message.
 
Back
Top