Runspace GetWPFCurrentThreadRunspace(InitialSessionState sessionState) { InitialSessionState clone = sessionState.Clone(); clone.ThreadOptions = PSThreadOptions.UseCurrentThread; SessionStateVariableEntry window = new SessionStateVariableEntry("Window", JobWindow, ""); SessionStateVariableEntry namedControls = new SessionStateVariableEntry("NamedControls", this.namedControls, ""); clone.Variables.Add(window); clone.Variables.Add(namedControls); return RunspaceFactory.CreateRunspace(clone); }
protected RunspaceBase(PSHost host, InitialSessionState initialSessionState) { if (host == null) { throw RunspaceBase._trace.NewArgumentNullException(nameof(host)); } if (initialSessionState == null) { throw RunspaceBase._trace.NewArgumentNullException(nameof(initialSessionState)); } this._host = host; this._initialSessionState = initialSessionState.Clone(); this.ApartmentState = initialSessionState.ApartmentState; this.ThreadOptions = initialSessionState.ThreadOptions; }
public RunspacePoolInternal(int minRunspaces, int maxRunspaces, System.Management.Automation.Runspaces.InitialSessionState initialSessionState, PSHost host) : this(minRunspaces, maxRunspaces) { if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException("initialSessionState"); } if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } this._initialSessionState = initialSessionState.Clone(); this.apartmentState = initialSessionState.ApartmentState; this.threadOptions = initialSessionState.ThreadOptions; this.host = host; this.pool = new Stack <Runspace>(); this.runspaceRequestQueue = new Queue <GetRunspaceAsyncResult>(); this.ultimateRequestQueue = new Queue <GetRunspaceAsyncResult>(); }
protected RunspaceBase(PSHost host, InitialSessionState initialSessionState) { if (host == null) { throw PSTraceSource.NewArgumentNullException("host"); } if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException("initialSessionState"); } Host = host; InitialSessionState = initialSessionState.Clone(); this.ThreadOptions = initialSessionState.ThreadOptions; #if !CORECLR // No ApartmentState In CoreCLR this.ApartmentState = initialSessionState.ApartmentState; #endif }