简体   繁体   English

C#任务列表和使用task.whenAny性能

[英]C# list of tasks and using task.whenAny performance

I have 10 different methods with the same return type "List". 我有10个不同的方法,且返回类型均为“列表”。 I am adding all the methods to a Task. 我将所有方法添加到任务。 Iterate through the task list and execute them. 遍历任务列表并执行它们。 I need to know which one is best for boosting up performance. 我需要知道哪个是最能提高性能的。 Task.whenAny or Parallel.invoke? Task.whenAny或Parallel.invoke?

Appreciate your responses. 感谢您的回应。

Task.WhenAll will wait for them all to complete in parallel. Task.WhenAll将等待它们并行完成。

Task.WhenAny will wait until the first one finishes. Task.WhenAny将等到第一个完成。

Task.WhenAll is probably what you want and is good for performance too. Task.WhenAll可能正是您想要的,而且对性能也有好处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM