Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to kill a working thread properly. I tried
Thread.Abort();


And

Thread.Interrupt();
Thread.Abort();


but none of this work. Any suggestion where i am going wrong will be helpful.
Posted
Updated 2-Jun-20 1:27am
Comments
PIEBALDconsult 14-Jan-14 23:35pm    
Then don't do that. Have you tried setting a semaphore that tells the thread to stop on its own?
agent_kruger 15-Jan-14 8:21am    
what is semaphore?
SofiaRodrigues 20-May-19 7:32am    
https://en.wikipedia.org/wiki/Semaphore_(programming) see this page on Wikipédia
agent_kruger 21-May-14 11:23am    
sir, can you explain what is "semaphore "?
Philippe Mori 25-Nov-16 10:24am    
Never kill a thread. Learn multithreading by reading books or doing tutorials. You don't want to improvise code without understanding how it works...

check the below link and i think u will got some relevant information about it
http://msdn.microsoft.com/en-us/library/7a2f3ay4.aspx[^]
 
Share this answer
 
Comments
agent_kruger 15-Jan-14 8:27am    
what is a "Worker"? and how do you use it? i am not getting a worker after writing using.System.Threading.
 
Share this answer
 
v2
Comments
agent_kruger 16-Jan-14 6:56am    
in my case when i write interupt and then abort, it does not do anything but before finishing the code block it gives an error "Thread Aborted". I took the whole code block in try catch and didn't throw any error message but it still shows error message. So, any idea how to stop the Thread?
Karthik_Mahalingam 16-Jan-14 7:03am    
you can use this property to check the thread is alive or not based on that you can kill it..

link
agent_kruger 16-Jan-14 7:04am    
I have already tried but it says the "Thread" is still alive. What should I do?
Karthik_Mahalingam 16-Jan-14 7:12am    
you need to kill it forcefully ??
agent_kruger 16-Jan-14 7:16am    
how?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900