|
-
January 26th, 2005, 03:03 AM
#1
[Resolved] Abort() command not working for a Thread?
Hi, everybody. I'm having an issue with threading. One of my threads keeps on running even after I've called the End command and my GUI exits, but the process continues to run until the thread has finished. I use the Abort() command, but the thread does not abort. I've tried a variety of things (including Join(), Interrupt(), Sleep(), myThread = Nothing...), but I can't seem to get the thread to JUST STOP.
Here's the piece of code I'm running:
Code:
If Me.activeThread.ThreadState = ThreadState.Running Then
Me.activeThread.Abort()
End If
Also, an aside, when I was doing Suspend() followed by Abort(), I got the ThreadState of 130... I don't think that's supposed to happen!
Any help with this issue is greatly appreciated.
... Mike. *_*
Last edited by MikeKraken; January 26th, 2005 at 08:10 PM.
Reason: added "Resolved" tag to subject line ^^
-
January 26th, 2005, 12:06 PM
#2
Re: Abort() command not working for a Thread?
Just a WAG, but are you sure that your thread is already not in a wait state, like maybe an IO wait, or a Monitor wait etc when you are trying to kill it?
-
January 26th, 2005, 07:31 PM
#3
Re: Abort() command not working for a Thread?
Well, I was trying this one as well...
Code:
Console.WriteLine("NO (before): " & Me.activeThread.ThreadState)
If Me.activeThread.IsAlive Then
Me.activeThread.Abort()
End If
Console.WriteLine("NO (after): " & Me.activeThread.ThreadState)
I always get a ThreadState of 0 (running) before checking if the thread is alive, and I was getting a ThreadState of 130 (???) afterward...
So as far as I know, it is actually running when I try to abort...
... Mike. O_o
Last edited by MikeKraken; January 26th, 2005 at 07:31 PM.
Reason: code tag mistake
-
January 26th, 2005, 08:11 PM
#4
Re: Abort() command not working for a Thread?
I found out how to ensure that the thread closes when the rest of the application does.
Code:
Me.activeThread.IsBackground = True
Woo hoo!
... Mike. ^_^
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|