等待任务。等待-僵局?
Task.Wait
await
.
public class TestController : ApiController{ public static async Task<string> Foo() { await Task.Delay(1).ConfigureAwait(false); return ""; } public async static Task<string> Bar() { return await Foo(); } public async static Task<string> Ros() { return await Bar(); } // GET api/test public IEnumerable<string> Get() { Task.WaitAll(Enumerable.Range(0, 10).Select(x => Ros()).ToArray()); return new string[] { "value1", "value2" }; // This will never execute }}
Get
await Task.Delay
?
杨魅力
慕村225694