B
Bob
My app shows a modal MDI parent form, and creates a timer that ticks every
ten minutes to boot unresposive users at 3 in the morning. Below is a
simplified working example with no time check. My question is, is it OK to
use End or it is there a cleaner way to close the app? Keep in mind that I
want everything taken down, including any warning dialogue box shown from
the timer, and any others that happen to be still open in the MDI parent
itself - so frm.Close does not work.
TIA,
Bob
'---------------------------------
Module Main
Private WithEvents tmr As Windows.Forms.Timer
Private frm As Form
Public Sub Main()
tmr = New Timer
tmr.Interval = 2000
tmr.Enabled = True
frm = New Form
frm.WindowState = FormWindowState.Maximized
frm.IsMdiContainer = True
frm.ShowDialog()
End Sub
Private DoingMessage As Boolean
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tmr.Tick
If DoingMessage Then
Beep()
End
Else
Dim msg As String = "This application will now shut down for the
night."
DoingMessage = True
If MsgBox(msg, MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
End
End If
DoingMessage = False
End If
End Sub
End Module
ten minutes to boot unresposive users at 3 in the morning. Below is a
simplified working example with no time check. My question is, is it OK to
use End or it is there a cleaner way to close the app? Keep in mind that I
want everything taken down, including any warning dialogue box shown from
the timer, and any others that happen to be still open in the MDI parent
itself - so frm.Close does not work.
TIA,
Bob
'---------------------------------
Module Main
Private WithEvents tmr As Windows.Forms.Timer
Private frm As Form
Public Sub Main()
tmr = New Timer
tmr.Interval = 2000
tmr.Enabled = True
frm = New Form
frm.WindowState = FormWindowState.Maximized
frm.IsMdiContainer = True
frm.ShowDialog()
End Sub
Private DoingMessage As Boolean
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tmr.Tick
If DoingMessage Then
Beep()
End
Else
Dim msg As String = "This application will now shut down for the
night."
DoingMessage = True
If MsgBox(msg, MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
End
End If
DoingMessage = False
End If
End Sub
End Module