protected virtual Task<bool?> ShowWindowAsync(FrameworkElement window, bool showModal)
{
// Note: no async/await because we use a TaskCompletionSource
if (showModal) // CTL-648 async modal fix
{
var tcs = new TaskCompletionSource<bool?>();
HandleCloseSubscription(window, null, (s, e) => tcs.SetResult(e.Result), true); // complete the task with DialogResult when dialog is closed
ShowWindow(window, true);
return tcs.Task;
}
return TaskHelper.Run(() => ShowWindow(window, showModal), true);
}
#endregion