Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi,

Thread is running or terminated; it cannot restart.

Thanks.
Posted
Comments
DamithSL 29-May-14 22:16pm    
click on Improve question Link on your question and include the code where you get the exception and also provide additional information like what you tried to fix this etc..

1 solution

You cannot restart a thread, there is no such concept (and that's good).

You create just a new thread object and then you start it by some other thread. Since that moment, no more calls to System.Threading.Thread.Start should be done. Your problem is that you are trying to do this operation, which makes no sense. Instead, you have to let this thread terminate or abort it. If you still need the thread, you can create another one, using the same delegate instance as a constructor, or some other one.

The alternatives are using thread pool or System.ComponentModel.BackgroundWorker:
http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx[^],
http://msdn.microsoft.com/en-us/library/vstudio/system.componentmodel.backgroundworker[^].

—SA
 
Share this answer
 

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