When does a Task actually start?
public void DoSomething() {
Task myTask = DoSomethingAsync();
Task.WaitAll(new[] { myTask }, 2000);
}
public async Task DoSomethingAsync() {
await SomethingElse();
}
Does it start immediately when initializing it in Task myTask = DoSomethingAsync();
or does it start when you say to wait for it in Task.WaitAll(new[] { myTask }, 2000);
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…