I created a Thread, and want to kill him. I found my Thread in Process.GetCurrentProcess().Threads
, but it has ProcessThread
class, and can't be cast to Thread
, so i can't kill him.
foreach (Thread thread in currentProcess.Threads)//throw error:unable to cast
{
if (thread.ManagedThreadId.Equals(processThreadId))
{
thread.Abort();
}
}