Catel.Services.UIVisualizerService.ShowWindowAsync C# (CSharp) Method

ShowWindowAsync() protected method

Shows the window.
protected ShowWindowAsync ( FrameworkElement window, bool showModal ) : Task
window FrameworkElement The window.
showModal bool If true, the window should be shown as modal.
return Task
        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