private void InitializeTask(DialogInitializationArguments args)
 {
     _hostAppName = args.AppName;
     _dataSource  = new WaitDialogDataSource();
     _window      = new WaitWindowDialog(args.AppMainWindowHandle, args.AppProcessId, null)
     {
         DataContext = _dataSource
     };
     _window.Cancelled += OnDialogCancelled;
     UpdateDialogStyle(args);
     StartApplication();
 }
 private void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return;
     }
     if (disposing)
     {
         _application?.Dispatcher?.Invoke(() =>
         {
             _window?.Close();
             _application?.Shutdown();
         });
         _window           = null;
         _application      = null;
         _isDialogAcquired = false;
     }
     _disposed = true;
 }