, , , , . ( ) , Thread.Abort() .
:
private Thread _myWorker;
void doSomething()
{
_myWorker = new Thread(...);
_myWorker.Start();
}
void killWorker()
{
_myWorker.Abort()
}
You should notice that then you call Abort()in the thread, it will throw a ThreadAbortException, which you must catch inside your working code and handle it for cleaning, etc. See Thread.Abort for details.
In addition, when your application disables its main thread (message loop, aka Application.Run), child threads will also be disabled.
source
share