Questions tagged «synchronizationcontext»

2
我为什么要麻烦使用Task.ConfigureAwait(continueOnCapturedContext:false);
考虑以下Windows窗体代码: private async void UpdateUIControlClicked(object sender, EventArgs e) { this.txtUIControl.Text = "I will be updated after await - i hope!"; await Task.Delay(5000).ConfigureAwait(continueOnCapturedContext: false); this.txtUIControl.Text = "I am updated now."; } 此处在第三行引发异常,因为在等待之后,代码将在非UI线程上执行。在哪里ConfigureAwait(false)有用?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.