我知道我可以像这样执行一个简单的延迟任务:
Task.Delay(iDelayInMilliseconds).ContinueWith(() => SomeMethod());
我可以像这样将两种不同的方法链式地作为连续任务:
Task.Run(() => SomeMethod()).ContinueWith(() => AnotherMethod());
我无法理解的是像这样的内容:
Task.Run(() => SomeMethod()).Delay(iDelayInMilliseconds).ContinueWith(() => AnotherMethod());
有效地说,我希望SomeMethod()执行后延迟一段时间再执行AnotherMethod()。
有人能帮我吗?
theTask.ContinueWith(t=>Thread.Sleep(iDelayInMilliseconds))
来进行延迟。 - momvart