Created
April 23, 2014 14:42
-
-
Save qwerty2501/11218041 to your computer and use it in GitHub Desktop.
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()=> | |
{ | |
var messageDialog = new MessageDialog("UI更新"); | |
await messageDialog.ShowAsync();//例外が発生する | |
}; | |
//DoAsync呼び出し時にすでにUIスレッドではない場合メソッドないで同期コンテキストからSend/PostしてもUIスレッドに戻ることはできない | |
await asyncObject.DoAsync(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment