是否有其中任务,不应使用任何情形? [英] Are there any scenario where Tasks should not be used?
本文介绍了是否有其中任务,不应使用任何情形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我读到过这样的异步编程4.0 preferred方式的任务。我只是想知道是否有任何使用情况下使用的任务不应该是pferred过正常的C#线程$ P $?
I am reading about Tasks been preferred way of doing async programming with 4.0. I am just wondering if there are any use cases where use of Tasks should not be preferred over normal c# threads?
推荐答案
由于工作
的使用底层线程池
(除非被标记为长时间运行),这是一个坏主意,用他们使用线程池
不建议,例如,只要
Since Task
s use the underlying ThreadPool
(unless marked as long running), it's a bad idea to use them whenever using a ThreadPool
is not advised e.g.
- 在长期的I /被执行阻塞任务队列和prevent其他任务O操作。
- 在做需要线程标识,如设置亲和力的操作。
这篇关于是否有其中任务,不应使用任何情形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文