/// <summary>
        /// Begin invocation of command specified in activity
        /// </summary>
        /// <param name="command">pipeline of command to execute</param>
        /// <param name="input">input collection</param>
        /// <param name="output">output collection</param>
        /// <param name="policy">policy to use for the activity</param>
        /// <param name="callback">optional callback</param>
        /// <param name="state">optional caller specified state</param>
        /// <returns>IAsyncResult</returns>
        internal IAsyncResult BeginInvokePowerShell(System.Management.Automation.PowerShell command,
                                                    PSDataCollection <PSObject> input, PSDataCollection <PSObject> output, PSActivityEnvironment policy,
                                                    AsyncCallback callback, object state)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            ConnectionAsyncResult result = new ConnectionAsyncResult(state, callback, command.InstanceId);

            _structuredTracer.OutOfProcessRunspaceStarted(command.ToString());

            ActivityInvoker invoker =
                new ActivityInvoker
            {
                Input       = input,
                Output      = output,
                Policy      = policy,
                PowerShell  = command,
                AsyncResult = result
            };

            result.Invoker = invoker;

            _requests.Enqueue(invoker);
            PerfCountersMgr.UpdateCounterByValue(
                PSWorkflowPerformanceCounterSetInfo.CounterSetId,
                PSWorkflowPerformanceCounterIds.ActivityHostMgrIncomingRequestsPerSec);
            PerfCountersMgr.UpdateCounterByValue(
                PSWorkflowPerformanceCounterSetInfo.CounterSetId,
                PSWorkflowPerformanceCounterIds.ActivityHostMgrPendingRequestsQueueLength);
            CheckAndStartServicingThread();
            return(result);
        }
Ejemplo n.º 2
0
 internal IAsyncResult BeginInvokePowerShell(System.Management.Automation.PowerShell command, PSDataCollection <PSObject> input, PSDataCollection <PSObject> output, PSActivityEnvironment policy, AsyncCallback callback, object state)
 {
     if (command != null)
     {
         ConnectionAsyncResult connectionAsyncResult = new ConnectionAsyncResult(state, callback, command.InstanceId);
         this._structuredTracer.OutOfProcessRunspaceStarted(command.ToString());
         ActivityInvoker activityInvoker = new ActivityInvoker();
         activityInvoker.Input       = input;
         activityInvoker.Output      = output;
         activityInvoker.Policy      = policy;
         activityInvoker.PowerShell  = command;
         activityInvoker.AsyncResult = connectionAsyncResult;
         ActivityInvoker activityInvoker1 = activityInvoker;
         connectionAsyncResult.Invoker = activityInvoker1;
         this._requests.Enqueue(activityInvoker1);
         PSOutOfProcessActivityController.PerfCountersMgr.UpdateCounterByValue(PSWorkflowPerformanceCounterSetInfo.CounterSetId, 19, (long)1, true);
         PSOutOfProcessActivityController.PerfCountersMgr.UpdateCounterByValue(PSWorkflowPerformanceCounterSetInfo.CounterSetId, 20, (long)1, true);
         this.CheckAndStartServicingThread();
         return(connectionAsyncResult);
     }
     else
     {
         throw new ArgumentNullException("command");
     }
 }