简体   繁体   中英

Does Task.WhenAny prioritize some tasks over others?

将多个已完成的任务传递给Task.WhenAny时,Task.WhenAny会优先选择完成哪个任务将返回任务?

When you want to know the exact behavior, you can often check the reference source . For instance, WhenAny can be found here .

When looking through the source, note that the returned task is not one of your tasks, but an internally-created task (either a CompleteOnInvokePromise instance or continuation of it), whose Result will be one of your tasks. In the case where you are passing completed tasks into WhenAny , the Result is immediately set to the first completed task it encounters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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