public ProgressDialogWindowViewModel(ProgressDialogWindow owner, ProgressDialogWindow.Options options, Task task)
        {
            _owner   = owner;
            _task    = task;
            _options = options;

            CancelCommand = new ProtectedCommand(OnCancelCommand, canExecuteCommand: _options.IsCancellable);

            CloseOnTaskCompletion();
            owner.Closed += OnOwnerClosed;
        }
        /// <summary>
        /// Prompts the user with the progress dialog and awaits the end of the <seealso cref="Task"/> to close
        /// itself.
        /// </summary>
        /// <param name="task">The <seealso cref="Task"/> instance to show progress for.</param>
        /// <param name="options">The options for the dialog.</param>
        /// <returns>A task that can be awaited to get the result of the operation.</returns>
        public static async Task PromptUserAsync(Task task, Options options)
        {
            var dialog = new ProgressDialogWindow(task, options);

            dialog.ShowModal();
            if (!dialog.ViewModel.WasCancelled)
            {
                // Await the task to get the value it holds or to force it to throw
                // the exception it holds if it failed.
                await task;
            }
        }
        /// <summary>
        /// Prompts the user with the progress dialog and awaits the end of the <seealso cref="Task{TResult}"/> to close
        /// itself.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="task">The <seealso cref="Task{TResult}"/> instance to show progress for.</param>
        /// <param name="options">The options for the dialog.</param>
        /// <returns>A task that can be awaited to get the result of the operation.</returns>
        public static async Task <T> PromptUserAsync <T>(Task <T> task, Options options)
        {
            var dialog = new ProgressDialogWindow(task, options);

            dialog.ShowModal();

            // Check if the dialog closed because the task completed or because the user cancelled the operation.
            if (dialog.ViewModel.WasCancelled)
            {
                return(default(T));
            }
            else
            {
                // Await the task to get the value it holds or to force it to throw
                // the exception it holds if it failed.
                return(await task);
            }
        }