Link to home
Start Free TrialLog in
Avatar of wellhole
wellhole

asked on

Thread Abort and Join

I'm trying to abort and join onto a thread so that I don't write over the new thread work with the old thread work. But, its not behaving nicely. For some reason, Abort() and Join() isn't waiting for the Finally block to end. Any ideas?
Private t as Thread = Nothing

Sub StartThread()
  If Not t Is Nothing Then
    Console.WriteLine("Abort")
    t.Abort()
    t.Join()
  End If
  Console.WriteLine("New")
  t = New Thread(AddressOf SomeFunction)
  t.IsBackground = True
  t.Start()
End Sub

Sub SomeFunction()
  Try
    ' Do stuff
  Catch
    ' Ignore
  Finally
    ' Free up resources
    Console.WriteLine("Finally")
  End Try
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ajb2222
ajb2222

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wellhole
wellhole

ASKER

I'm sorry ajb2222. That doesn't help. I can't wait seconds or minutes for a database query. Only abort can get out of that.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahh. I screwed up on this question. I'm going to start over with a better description.