Home > Mobile >  How to automatically remove threads from the list of threads in c#
How to automatically remove threads from the list of threads in c#

Time:10-10

As it is clear from the title
I want remove automatically threads from threads list when thread jobs done.
like:

Thread thr;
if(thr.done)
{
    threadlist.remove(thr);
}

CodePudding user response:

If you check if the thread is finished with IsAlive and use Abort() to finish the thread...

if(!thr.IsAlive)
{
   thr.Abort();
   threadlist.remove(thr);
}
  • Related