internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { this.instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo)connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this.connectionInfo = ((NewProcessConnectionInfo)connectionInfo).Copy(); } base.host = host; this.applicationArguments = applicationArguments; this.availableForConnection = false; this.dispatchTable = new DispatchTable <object>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } this.CreateDSHandler(typeTable); }
internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectCommands == null) { throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]"); } if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo)connectionInfo).Copy(); } base.instanceId = instanceId; base.minPoolSz = -1; base.maxPoolSz = -1; PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); this.connectCommands = connectCommands; this.Name = name; base.host = host; this.dispatchTable = new DispatchTable <object>(); this.SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null)); this.CreateDSHandler(typeTable); this.availableForConnection = isDisconnected; }
internal RemoteRunspace(TypeTable typeTable, RunspaceConnectionInfo connectionInfo, PSHost host, PSPrimitiveDictionary applicationArguments, string name = null, int id = -1) { 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; PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId); this._applicationArguments = applicationArguments; PSEtwLog.LogOperationalVerbose(PSEventId.RunspaceConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { base.InstanceId.ToString() }); if (connectionInfo is WSManConnectionInfo) { this._connectionInfo = ((WSManConnectionInfo)connectionInfo).Copy(); this._originalConnectionInfo = ((WSManConnectionInfo)connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this._connectionInfo = ((NewProcessConnectionInfo)connectionInfo).Copy(); this._originalConnectionInfo = ((NewProcessConnectionInfo)connectionInfo).Copy(); } this._runspacePool = new System.Management.Automation.Runspaces.RunspacePool(1, 1, typeTable, host, applicationArguments, connectionInfo, name); this.Id = id; this.SetEventHandlers(); }
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() }); } } }
protected override IAsyncResult CoreOpen(bool isAsync, AsyncCallback callback, object asyncState) { PSEtwLog.SetActivityIdForCurrentThread(base.InstanceId); PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolOpen, PSOpcode.Open, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[0]); lock (base.syncObject) { base.AssertIfStateIsBeforeOpen(); base.stateInfo = new RunspacePoolStateInfo(RunspacePoolState.Opening, null); } base.RaiseStateChangeEvent(base.stateInfo); RunspacePoolAsyncResult result = new RunspacePoolAsyncResult(base.instanceId, callback, asyncState, true); this.openAsyncResult = result; this.dataStructureHandler.CreateRunspacePoolAndOpenAsync(); return(result); }
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() }); }