Microsoft.ManagementConsole.Advanced.WaitCursor.Run C# (CSharp) Method

Run() private method

private Run ( ) : bool
return bool
        internal bool Run()
        {
            bool flag;
            if (this._insideModalLoop)
            {
                throw new InvalidOperationException(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.ExceptionInternalConsoleDialogHostAlreadyInsideModalLoop));
            }
            Timer timer = new Timer();
            try
            {
                Application.UseWaitCursor = true;
                this._insideModalLoop = true;
                timer.Tick += new EventHandler(this.OnTimer);
                timer.Interval = (int) this.Timeout.TotalMilliseconds;
                timer.Start();
                this.InnerStart();
                ModalLoop.Run();
                flag = !this._timedOut;
            }
            finally
            {
                timer.Dispose();
                this._timedOut = false;
                this._quitMessagePosted = false;
                this._insideModalLoop = false;
                Application.UseWaitCursor = false;
            }
            return flag;
        }

Usage Example

Example #1
0
 private DialogResult ShowDialog(WaitCursor waitCursor, ShowDialogCallback callback)
 {
     DialogResult result;
     IWin32Window owner = null;
     if (this._platform == null)
     {
         throw new InvalidOperationException(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.ExceptionInternalConsoleDialogHostOwnerNotInitialized));
     }
     try
     {
         BeginModalLoopConsoleDialogCommand command = new BeginModalLoopConsoleDialogCommand();
         command.OwnerId = this._ownerId;
         BeginModalLoopConsoleDialogCommandResult result2 = (BeginModalLoopConsoleDialogCommandResult) this._platform.ProcessCommand(command);
         owner = result2.Window;
         if ((waitCursor != null) && waitCursor.Run())
         {
             return waitCursor.DialogResult;
         }
         result = callback(owner);
     }
     finally
     {
         EndModalLoopConsoleDialogCommand command2 = new EndModalLoopConsoleDialogCommand();
         command2.OwnerId = this._ownerId;
         this._platform.ProcessCommand(command2);
     }
     return result;
 }