Results 1 to 2 of 2

Thread: Killing a thread when the application closes...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210

    Question Killing a thread when the application closes...

    I have a threading that goes on forever so even when I close the application, it still remains in the memory.

    I've tried
    VB Code:
    1. Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    2.         Dim f As New Threading.Thread(AddressOf NewTime)
    3.         If f.IsAlive = True Then
    4.             MsgBox("thread f is alive")
    5.         ElseIf f.IsAlive = False Then
    6.             MsgBox("thread f is not alive")
    7.             f.Abort()
    8.         End If
    9.     End Sub
    but it didn't work because it said that the thread was not alive.

    So I guess I'll have to somehow refer to my existing dimmed thread... but how would I do that?

    Thanks.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You can store a reference to the existing thead in a module. Then you can access it and abort it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width