private async void Button_Click(object sender, RoutedEventArgs e) { var dialog = new WaitWindow(); var task = WorkAsync(dialog.Progress); var dialogTask = dialog.ShowDialogAsync(); await task; dialog.Close(); await dialogTask; }