How to get a link to a TPL task thread in C #?

When I create a task like

Task task = Task.Factory.StartNew(() => someMethod(args));

in C # 4.0+, how can I get a link to the thread of this task?

Is it possible that the task runs in the same thread that created the task, or spawns more than one thread?

Update:
The reasons are as follows:

  • I would like to define the task flow in the debugger (and specify its name), etc.

Is a task always created in a separate thread from the one in which the task was created?
Is it one, zero or more than one thread?
Is it running on the same kernel?
It is important to know, because, for example, I can sleep in the main thread, thinking that I am freezing the background worker

Update:
Useful answer:

+5
3

, , ?

, , TPL , , , , ​​ ( ), . , ; , , TPL . , , . , ( ), , - , , .

, ?

. , , . , , , , . LongRunning, Task. TaskScheduler, , .

?

, .

, , , , ,

. , , . : - , , , , .

+7

:

System.Threading.Thread.CurrentThread

, , TPL , " " .

+3

Task.Factory.StartNew() (. ). , , TaskScheduler ( TaskScheduler , ).

.Net 4 TaskScheduler ThreadPool (. ), , ThreadPool Thread , .

ThreadPool.

, .

, , ThreadPool Thread,

+3

All Articles