根据this question的回答,没有办法有效地使用 LINQ 来执行 IO 密集型任务。有没有办法获得更好的控制,或者 LINQ 不适合此类任务?
最佳答案
我不同意你的结论。在另一个问题中,卢克表示:
From the MSDN documentation: "Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query". WithDegreeOfParallelism is just a hint that PLINQ should use no more than n threads.
Plinq 仅决定在代码中使用两个线程而不是十个线程这一事实并不意味着它不适合 IO 密集型任务。这意味着(很可能)两个线程最适合您的代码,而不是十个。
关于c# - 如何使用 PLINQ 执行 IO 密集型任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1812807/