Why does a Thread (which I set IsBackgroundthread
to True
) is not running with the threadpool Threads ?
/*1*/ volatile bool r = false;
/*2*/ var g= new Thread(() => r=Thread.CurrentThread.IsThreadPoolThread );
/*3*/ g.IsBackground = true;
/*4*/ g.Start();
/*5*/ g.Join();
/*6*/ Console.WriteLine(r); //false
While this code (obviously) does run at a threadpool thread ?
Task.Factory.StartNew(()=>Console.Write(Thread.CurrentThread.IsThreadPoolThread)); //true
Console.ReadLine();
p.s. (I know that Task are (by default)run at a background threads and they run in a threadpool , but my question is about a similar situation where I set a thread to run at background).)