Why was “SwitchTo” removed from Async CTP / Release?

后端 未结 3 1272
傲寒
傲寒 2020-11-29 09:49

I tried to use the SwitchTo method today to switch to the GUI thread, and found that the example I lifted it from does not work, simply because the method is not there.

3条回答
  •  感动是毒
    2020-11-29 09:50

    ConfigureAwait is actually more dangerous than SwitchTo. Mentally tracking the current context and the last SwitchTo call is no more difficult than tracking where a variable was last assigned. On the other hand, ConfigureAwait switches context if and only if the call actually ran asynchronously. If the task was already completed, the context is preserved. You have no control over this.

提交回复
热议问题