I don\'t know the difference beetween await a task and use task.Wait() but for the MessageDialog.ShowAsync method with the first it works but not with the second (while the two
Showing the dialog (and responding to button click in it) has to be done from the UI thread. But if you call Wait()
on the UI thread, you're basically saying that nothing else can happen on that thread, until that Task
completes. That's why the dialog can't be shown and that's also why your application freezes.
So, the UI thread is waiting for the dialog, but the dialog is waiting for the UI thread, which is a classical deadlock. I believe using Wait()
on the UI thread is the most common cause of deadlocks in C# 5 GUI applications.
task.Wait() blocks until the task is complete, while await continues processing. My guess is that because the UI is blocked, the message dialog cannot appear.