This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncClass | |
{ | |
//この通知によってライブラリユーザはUIを更新することが高いと予想される | |
public event Action SomeEventHandler; | |
public async Task DoAsync() | |
{ | |
//ここまでUIスレッドで実行されているとする | |
//UIスレッドの同期コンテキストをキャッシュする |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void Button_Click_1(object sender, RoutedEventArgs e) | |
{ | |
//ConfigureAwait(false)でUIスレッドに戻さない | |
await Task.Delay(5).ConfigureAwait(false); | |
var asyncObject = new AsyncClass(); | |
asyncObject.SomeEventHandler += async()=> | |
{ | |
NewerOlder