Can threads started by Tasks Parallel Library act as foreground threads?

后端 未结 4 1436
情话喂你
情话喂你 2020-12-11 06:28

MSDN documentation indicates that threads started by the TPL will enjoy better scheduling. However, since the threads are based upon ThreadPool, they will be implemented as

4条回答
  •  暖寄归人
    2020-12-11 07:20

    The TPL does not really give you Threads, it lets you create Tasks. Tasks can be executed on different threads, so Task != Thread.

    As with the plain Threadpool, it would not be a good idea to change any Thread-properties.

    But you problem could be easily solved by Waiting for any outstanding tasks from the main thread. You usually want to catch and handle their exceptions too.

提交回复
热议问题