Example #1
0
        /// <summary>
        /// Displays a single message box to the user
        /// </summary>
        /// <param name="viewModel">The view model</param>
        /// <returns></returns>
        public Task ShowMessage(MessageBoxDialogViewModel viewModel)
        {
            // Create a task completion source
            var tcs = new TaskCompletionSource <bool>();

            // Run on UI thread
            Application.Current.Dispatcher.Invoke(async() =>
            {
                try
                {
                    // Show the dialog box
                    await new DialogMessageBox().ShowDialog(viewModel);
                }
                finally
                {
                    // Flag we are done
                    tcs.SetResult(true);
                }
            });

            // Return the task once complete
            return(tcs.Task);
        }
Example #2
0
 public Task ShowMessage(MessageBoxDialogViewModel viewModel)
 {
     return(new DialogMessageBox().ShowDialog(viewModel));
 }