When does Task.Run flow SynchronizationContext with ExecutionContext?

前端 未结 1 883
北荒
北荒 2021-01-21 03:47

This article from states that SynchronizationContext may flow with ExecutionContext:

private void button1_Click(object sen         


        
相关标签:
1条回答
  • 2021-01-21 04:13

    When does Task.Run flow SynchronizationContext with ExecutionContext?

    Never.

    The point of that article is that (the public API for) flowing ExecutionContext will flow SynchronizationContext. But Task.Run (and "pretty much any asynchronous operation whose core implementation resides in mscorlib") will never do this.

    The paragraph starting with "My expectation is valid if" is hypothetical. He's describing what would happen if Task.Run use the public API for flowing ExecutionContext. This would cause problems if it did this. That's why it doesn't ever do this.

    0 讨论(0)
提交回复
热议问题