Exemple #1
0
 private void SetRunspaceState(RunspaceState state, Exception reason)
 {
     lock (this._syncRoot)
     {
         if (state != this._runspaceStateInfo.State)
         {
             this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(state, reason);
             System.Management.Automation.Runspaces.RunspaceAvailability currentAvailability = this._runspaceAvailability;
             base.UpdateRunspaceAvailability(this._runspaceStateInfo.State, false);
             this._runspaceEventQueue.Enqueue(new RunspaceEventQueueItem(this._runspaceStateInfo.Clone(), currentAvailability, this._runspaceAvailability));
             PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceStateChange, PSOpcode.Open, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { state.ToString() });
         }
     }
 }
Exemple #2
0
 internal RemoteRunspace(System.Management.Automation.Runspaces.RunspacePool runspacePool)
 {
     this._runningPipelines   = new ArrayList();
     this._syncRoot           = new object();
     this._runspaceStateInfo  = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen);
     this._version            = PSVersionInfo.PSVersion;
     this._runspaceEventQueue = new Queue <RunspaceEventQueueItem>();
     this.id = -1;
     if ((runspacePool.RunspacePoolStateInfo.State != RunspacePoolState.Disconnected) || !(runspacePool.ConnectionInfo is WSManConnectionInfo))
     {
         throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "InvalidRunspacePool", new object[0]);
     }
     this._runspacePool = runspacePool;
     this._runspacePool.RemoteRunspacePoolInternal.SetMinRunspaces(1);
     this._runspacePool.RemoteRunspacePoolInternal.SetMaxRunspaces(1);
     this._connectionInfo = ((WSManConnectionInfo)runspacePool.ConnectionInfo).Copy();
     this.SetRunspaceState(RunspaceState.Disconnected, null);
     this._runspaceAvailability = this._runspacePool.RemoteRunspacePoolInternal.AvailableForConnection ? System.Management.Automation.Runspaces.RunspaceAvailability.None : System.Management.Automation.Runspaces.RunspaceAvailability.Busy;
     this.SetEventHandlers();
     PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId);
     PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() });
 }
Exemple #3
0
 internal RemoteRunspace(System.Management.Automation.Runspaces.RunspacePool runspacePool)
 {
     this._runningPipelines = new ArrayList();
     this._syncRoot = new object();
     this._runspaceStateInfo = new System.Management.Automation.Runspaces.RunspaceStateInfo(RunspaceState.BeforeOpen);
     this._version = PSVersionInfo.PSVersion;
     this._runspaceEventQueue = new Queue<RunspaceEventQueueItem>();
     this.id = -1;
     if ((runspacePool.RunspacePoolStateInfo.State != RunspacePoolState.Disconnected) || !(runspacePool.ConnectionInfo is WSManConnectionInfo))
     {
         throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "InvalidRunspacePool", new object[0]);
     }
     this._runspacePool = runspacePool;
     this._runspacePool.RemoteRunspacePoolInternal.SetMinRunspaces(1);
     this._runspacePool.RemoteRunspacePoolInternal.SetMaxRunspaces(1);
     this._connectionInfo = ((WSManConnectionInfo) runspacePool.ConnectionInfo).Copy();
     this.SetRunspaceState(RunspaceState.Disconnected, null);
     this._runspaceAvailability = this._runspacePool.RemoteRunspacePoolInternal.AvailableForConnection ? System.Management.Automation.Runspaces.RunspaceAvailability.None : System.Management.Automation.Runspaces.RunspaceAvailability.Busy;
     this.SetEventHandlers();
     PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId);
     PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() });
 }