예제 #1
0
 public void StartWaitDialogWithCallback(string caption, string waitMessage, string progressText,
                                         bool isCancelable, int delayToShowDialog, bool showProgress, int totalSteps, int currentStep,
                                         IWaitDialogCallback callback)
 {
     StartWaitDialogHelper(caption, waitMessage, progressText, delayToShowDialog, isCancelable,
                           showProgress, currentStep, totalSteps, callback);
 }
예제 #2
0
 internal Session(IWaitDialog dialog, IProgress <WaitDialogProgressData> progress, CancellationToken token,
                  IWaitDialogCallback callback)
 {
     _dialog = dialog;
     Validate.IsNotNull(progress, nameof(progress));
     Progress = progress;
     UserCancellationToken = token;
     Callback = callback;
 }
 public void CloseDialog()
 {
     if (_disposed)
     {
         return;
     }
     if (_isDialogActive)
     {
         _provider.Close();
     }
     _isDialogActive       = false;
     _cancellationCallback = null;
 }
        public void Show(TimeSpan delayToShowDialog, DialogShowArguments showArguments, IWaitDialogCallback callback = null)
        {
            if (_disposed)
            {
                return;
            }
            if (showArguments == null)
            {
                throw new ArgumentNullException(nameof(showArguments));
            }
            ThreadHelper.ThrowIfNotOnUIThread(nameof(Show));
            EnsureInitialized();

            var activeWindow = NativeMethods.NativeMethods.GetActiveWindow();
            var windowText   = NativeMethods.NativeMethods.GetWindowText(GetRootOwnerWindow(activeWindow));

            showArguments.SetActiveWindowArgs(windowText, activeWindow);
            IsCancelled           = false;
            _cancellationCallback = callback;
            ShowInternalAsync(delayToShowDialog, showArguments).Forget();
        }
예제 #5
0
 private void StartWaitDialogHelper(string caption, string waitMessage, string progressText,
                                    int delayToShowDialog, bool isCancellable, bool isProgressVisible,
                                    int currentStepCount = 0, int totalStepCount = -1, IWaitDialogCallback callback = null)
 {
     if (!ThreadHelper.CheckAccess())
     {
         ThreadHelper.Generic.Invoke(() =>
         {
             StartWaitDialogHelper(caption, waitMessage, progressText, delayToShowDialog,
                                   isCancellable, isProgressVisible, currentStepCount, totalStepCount, callback);
         });
     }
     else
     {
         ThreadHelper.ThrowIfNotOnUIThread(nameof(StartWaitDialogHelper));
         lock (_syncObject)
         {
             if (_instance == null)
             {
                 _instance = WaitDialog.AcquireInstance();
             }
             if (_instance == null)
             {
                 _isDialogStarted = true;
             }
             else
             {
                 _isUiSuppressed = IsUiSuppressed();
                 if (!_isUiSuppressed)
                 {
                     try
                     {
                         var args = new DialogShowArguments(caption, waitMessage, progressText, isCancellable,
                                                            isProgressVisible, currentStepCount, totalStepCount)
                         {
                             AppMainWindowHandle = GetPrimaryWindowHandle()
                         };
                         _instance.Show(TimeSpan.FromSeconds(delayToShowDialog), args, callback);
                         _isDialogStarted = true;
                     }
                     catch
                     {
                         WaitDialog.ReleaseInstance(_instance);
                         _instance = null;
                         throw;
                     }
                 }
                 else
                 {
                     _isDialogStarted = true;
                 }
             }
         }
     }
 }