Await list of async predicates, but drop out on first false

后端 未结 6 871
孤街浪徒
孤街浪徒 2021-01-12 21:20

Imagine the following class:

public class Checker
{
   public async Task Check() { ... }
}

Now, imagine a list of instances of

6条回答
  •  借酒劲吻你
    2021-01-12 21:48

    You could do

    checkers.All(c => c.Check().Result);
    

    but that would run the tasks synchronously, which may be very slow depending on the implementation of Check().

提交回复
热议问题