console unload event?

  • Thread starter Thread starter Keith Langer
  • Start date Start date
K

Keith Langer

Is there some event that gets fired when a console window is closed?
I have cleanup code which needs to abort several threads.

Keith
 
Off the top of my head, the only thing I can think of is the finalize method
of your console class. This will only clear things up when garbage
collection is kicked off, so it is probably not the best option.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Keith,

You should terminate all your threads when your Sub Main exits. You
can use a Try/Finally. See my code below


Module Module1
Sub Main()
Dim thrd As New Threading.Thread(AddressOf DoWork)
thrd.Start()
Try
Do While True
System.Threading.Thread.Sleep(10)
Loop
Catch
Finally
Try
thrd.Abort()
Catch
End Try
End Try
End Sub

Private Sub DoWork()
Try
While True
System.Threading.Thread.Sleep(10)
End While
Catch ex As Exception
End Try
End Sub

End Module
 
Back
Top