Exemplo n.º 1
0
 private void AddAction(EventAction action, bool processSynchronously)
 {
     if (processSynchronously)
     {
         action.Args.EventProcessed = new ManualResetEventSlim();
     }
     lock (((ICollection) this.actionQueue).SyncRoot)
     {
         this.actionQueue.Enqueue(action);
     }
     this.PulseEngine();
 }
Exemplo n.º 2
0
 private void InvokeAction(EventAction nextAction, out bool addActionBack)
 {
     lock (this.actionProcessingLock)
     {
         this.processingAction = nextAction;
         addActionBack = false;
         SessionStateInternal engineSessionState = this.context.EngineSessionState;
         if (nextAction.Sender.Action != null)
         {
             this.context.EngineSessionState = nextAction.Sender.Action.ScriptBlock.SessionStateInternal;
         }
         Runspace defaultRunspace = Runspace.DefaultRunspace;
         try
         {
             Runspace.DefaultRunspace = this.context.CurrentRunspace;
             if (nextAction.Sender.Action != null)
             {
                 nextAction.Sender.Action.Invoke(nextAction.Sender, nextAction.Args);
             }
             else
             {
                 nextAction.Sender.HandlerDelegate(nextAction.Sender, nextAction.Args);
             }
         }
         catch (Exception exception)
         {
             CommandProcessorBase.CheckForSevereException(exception);
             if (exception is PipelineStoppedException)
             {
                 this.AddAction(nextAction, false);
                 addActionBack = true;
             }
         }
         finally
         {
             ManualResetEventSlim eventProcessed = nextAction.Args.EventProcessed;
             if (!addActionBack && (eventProcessed != null))
             {
                 eventProcessed.Set();
             }
             Runspace.DefaultRunspace = defaultRunspace;
             this.context.EngineSessionState = engineSessionState;
             this.processingAction = null;
         }
     }
 }