Synchronization context for Task.Delay

2019-07-28 21:06发布

I could find out that, Task.Run executes always on threads from .NET Framework threads pool (TaskScheduler.Default). I suppose, that it is the same with Task.Delay, but I'm not sure.

MSDN says for Task.Delay only:

Creates a task that will complete after a time delay

Therefore the question: Where (in which synchronization context) runs Task.Delay?

1条回答
相关推荐>>
2楼-- · 2019-07-28 21:40

Task.Delay doesn't run anywhere. It just creates a task that completes after the specified time. Unlike Task.Run it's not accepting a delegate of yours to run somewhere. Most tasks won't represent the execution of some method on another thread. Task.Run is one of few methods that do that.

查看更多
登录 后发表回答