protected RunspacePoolInternal(int minRunspaces, int maxRunspaces)
 {
     this.runspaceList = new List<Runspace>();
     this.syncObject = new object();
     this.apartmentState = System.Threading.ApartmentState.Unknown;
     if (maxRunspaces < 1)
     {
         throw PSTraceSource.NewArgumentException("maxRunspaces", resBaseName, "MaxPoolLessThan1", new object[0]);
     }
     if (minRunspaces < 1)
     {
         throw PSTraceSource.NewArgumentException("minRunspaces", resBaseName, "MinPoolLessThan1", new object[0]);
     }
     if (minRunspaces > maxRunspaces)
     {
         throw PSTraceSource.NewArgumentException("minRunspaces", resBaseName, "MinPoolGreaterThanMaxPool", new object[0]);
     }
     this.maxPoolSz = maxRunspaces;
     this.minPoolSz = minRunspaces;
     this.stateInfo = new System.Management.Automation.RunspacePoolStateInfo(RunspacePoolState.BeforeOpen, null);
     this.instanceId = Guid.NewGuid();
     PSEtwLog.SetActivityIdForCurrentThread(this.instanceId);
     this.cleanupInterval = DefaultCleanupPeriod;
     this.cleanupTimer = new Timer(new TimerCallback(this.CleanupCallback), null, -1, -1);
 }
 protected RunspacePoolInternal(int minRunspaces, int maxRunspaces)
 {
     this.runspaceList   = new List <Runspace>();
     this.syncObject     = new object();
     this.apartmentState = System.Threading.ApartmentState.Unknown;
     if (maxRunspaces < 1)
     {
         throw PSTraceSource.NewArgumentException("maxRunspaces", resBaseName, "MaxPoolLessThan1", new object[0]);
     }
     if (minRunspaces < 1)
     {
         throw PSTraceSource.NewArgumentException("minRunspaces", resBaseName, "MinPoolLessThan1", new object[0]);
     }
     if (minRunspaces > maxRunspaces)
     {
         throw PSTraceSource.NewArgumentException("minRunspaces", resBaseName, "MinPoolGreaterThanMaxPool", new object[0]);
     }
     this.maxPoolSz  = maxRunspaces;
     this.minPoolSz  = minRunspaces;
     this.stateInfo  = new System.Management.Automation.RunspacePoolStateInfo(RunspacePoolState.BeforeOpen, null);
     this.instanceId = Guid.NewGuid();
     PSEtwLog.SetActivityIdForCurrentThread(this.instanceId);
     this.cleanupInterval = DefaultCleanupPeriod;
     this.cleanupTimer    = new Timer(new TimerCallback(this.CleanupCallback), null, -1, -1);
 }
 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>();
 }
 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>();
 }
 internal RunspacePoolInternal()
 {
     this.runspaceList = new List<Runspace>();
     this.syncObject = new object();
     this.apartmentState = System.Threading.ApartmentState.Unknown;
 }
Exemple #6
0
 public void SetApartment(System.Threading.ApartmentState state)
 {
     mApartment = state;
 }
Exemple #7
0
 public void TrySetApartmentState(System.Threading.ApartmentState state)
 {
     threadField.TrySetApartmentState(state);
 }
 internal RunspacePoolInternal()
 {
     this.runspaceList   = new List <Runspace>();
     this.syncObject     = new object();
     this.apartmentState = System.Threading.ApartmentState.Unknown;
 }
Exemple #9
0
 private void InitializeInternal()
 {
     System.Threading.ApartmentState state =
         System.Threading.Thread.CurrentThread.GetApartmentState();
     LogInfo(LogGroups.Console, state.ToString() + "\n");
 }