Example #1
0
        protected override sealed void EndProcessing()
        {
            try {
                _asyncCmdletState = AsyncCmdletState.EndProcess;
                // let's not even bother doing all this if they didn't even
                // override the method.
                if (IsOverridden(Constants.Methods.EndProcessingAsyncMethod))
                {
                    // just before we kick stuff off, let's make sure we consume the dynamicaparmeters
                    if (!_consumedDynamicParameters)
                    {
                        ConsumeDynamicParameters();
                        _consumedDynamicParameters = true;
                    }

                    // just use our async/message pump to handle this activity
                    AsyncRun(EndProcessingAsync);
                }

                // make sure that we mark progress complete.
                if (_progressTrackers.Any())
                {
                    AllProgressComplete();
                }
            } finally {
                if (_asyncCmdletState == AsyncCmdletState.EndProcess)
                {
                    // If the state was changed elsewhere, don't assume that we're in the next state
                    _asyncCmdletState = AsyncCmdletState.EndProcessCompleted;
                }
            }
        }
Example #2
0
        protected override sealed void StopProcessing()
        {
#if DEBUG
            Log("StopProcessing", "[{0}/{1}] «{2}»".format(MyInvocation.PipelineLength, MyInvocation.PipelinePosition, MyInvocation.Line));
#endif

            try {
                CmdletState = AsyncCmdletState.StopProcess;
                Cancel();
                // let's not even bother doing all this if they didn't even
                // override the method.
                if (IsOverridden(Constants.Methods.StopProcessingAsyncMethod))
                {
                    // just use our async/message pump to handle this activity
                    AsyncRun(StopProcessingAsync);
                }
                if (_progressTrackers.Any())
                {
                    AllProgressComplete();
                }
            } finally {
                if (CmdletState == AsyncCmdletState.StopProcess)
                {
                    CmdletState = AsyncCmdletState.StopProcessCompleted;
                }
            }
        }
Example #3
0
        protected override sealed void BeginProcessing()
        {
            try {
                _asyncCmdletState = AsyncCmdletState.BeginProcess;

                ProcessHeldMessages();

                if (IsCanceled)
                {
                    return;
                }

                // let's not even bother doing all this if they didn't even
                // override the method.
                if (IsOverridden(Constants.Methods.BeginProcessingAsyncMethod))
                {
                    // just before we kick stuff off, let's make sure we consume the dynamicaparmeters
                    if (!_consumedDynamicParameters)
                    {
                        ConsumeDynamicParameters();
                        _consumedDynamicParameters = true;
                    }
                    // just use our async/message pump to handle this activity
                    AsyncRun(BeginProcessingAsync);
                }
            } finally {
                if (_asyncCmdletState == AsyncCmdletState.BeginProcess)
                {
                    // If the state was changed elsewhere, don't assume that we're in the next state
                    _asyncCmdletState = AsyncCmdletState.BeginProcessCompleted;
                }
            }
        }
Example #4
0
        protected override sealed void ProcessRecord()
        {
#if DEBUG
            Log("ProcessRecord", "[{0}/{1}] «{2}»".format(MyInvocation.PipelineLength, MyInvocation.PipelinePosition, MyInvocation.Line));
#endif

            try {
                CmdletState = AsyncCmdletState.ProcessRecord;
                ProcessHeldMessages();

                // let's not even bother doing all this if they didn't even
                // override the method.
                if (IsOverridden(Constants.Methods.ProcessRecordAsyncMethod))
                {
                    // just before we kick stuff off, let's make sure we consume the dynamicaparmeters
                    if (!_consumedDynamicParameters)
                    {
                        ConsumeDynamicParameters();
                        _consumedDynamicParameters = true;
                    }

                    // just use our async/message pump to handle this activity
                    AsyncRun(ProcessRecordAsync);
                }
            } finally {
                if (CmdletState == AsyncCmdletState.ProcessRecord)
                {
                    // If the state was changed elsewhere, don't assume that we're in the next state
                    CmdletState = AsyncCmdletState.ProcessRecordCompleted;
                }
            }
        }
Example #5
0
 protected override sealed void StopProcessing()
 {
     try {
         _asyncCmdletState = AsyncCmdletState.StopProcess;
         Cancel();
         // let's not even bother doing all this if they didn't even
         // override the method.
         if (IsOverridden(Constants.Methods.StopProcessingAsyncMethod))
         {
             // just use our async/message pump to handle this activity
             AsyncRun(StopProcessingAsync);
         }
         if (_progressTrackers.Any())
         {
             AllProgressComplete();
         }
     } finally {
         if (_asyncCmdletState == AsyncCmdletState.StopProcess)
         {
             _asyncCmdletState = AsyncCmdletState.StopProcessCompleted;
         }
     }
 }