Is Task.Factory.StartNew() guaranteed to create at least one new thread?

前端 未结 6 1957
一生所求
一生所求 2021-01-24 14:38

I understand that the TPL does not necessarily create a new thread for every task in a parallel set, but does it always create at least one? eg:

private void MyF         


        
6条回答
  •  太阳男子
    2021-01-24 15:20

    That's up to whatever the current default TaskScheduler is. You can just about envisage someone doing something horrific like implementing a SynchronousTaskScheduler that executes the task body during QueueTask and sets it to complete before returning.

    Assuming you're not letting someone else muck about with your task schedulers, you shouldn't have to worry about it.

提交回复
热议问题