UIAutomation.HasTimeoutCmdletBase.CheckTimeout C# (CSharp) Method

CheckTimeout() private method

private CheckTimeout ( GetWindowCmdletBase cmdlet, ICollection aeWindowList, bool fromCmdlet ) : void
cmdlet GetWindowCmdletBase
aeWindowList ICollection
fromCmdlet bool
return void
        private void CheckTimeout(GetWindowCmdletBase cmdlet,
                                  ICollection aeWindowList,
                                  bool fromCmdlet)
        {
            cmdlet.WriteVerbose(cmdlet, "OnSleep scriptblocks");
            SleepAndRunScriptBlocks(this);
            DateTime nowDate = DateTime.Now;
            WriteVerbose(this, "process: " +
                         cmdlet.ProcessName +
                         ", name: " +
                         cmdlet.Name +
                         ", seconds: " + (nowDate - StartDate).TotalSeconds);
            try {
                if ((null == aeWindowList || aeWindowList.Count <= 0) &&
                    !((nowDate - StartDate).TotalSeconds > Timeout/1000)) return;
                if (null == aeWindowList) {
                    Wait = false;
                    var eReturn =
                    // Exception eReturn =
                        new Exception(
                            CmdletName(this) + ": timeout expired for process: " +
                            cmdlet.ProcessName + ", title: " + cmdlet.Name);
                    throw(eReturn);
                } // else{ // OK
                // }
                    
                Wait &= cmdlet.WaitNoWindow;
                /*
                if (!cmdlet.WaitNoWindow) {
                    Wait = false;
                }
                */
                // break;
                
            } catch (Exception eEvaluatingWindowOrMeasuringTimeout) {
                WriteDebug(this, "exception: " +
                           eEvaluatingWindowOrMeasuringTimeout.Message);
                
                cmdlet.WriteError(
                    cmdlet,
                    "An error raised during checking the timeout. " +
                    eEvaluatingWindowOrMeasuringTimeout.Message,
                    "CheckingTimeout",
                    ErrorCategory.InvalidOperation,
                    true);
            }
        }
    }