RunspacePool RunspacePool RunspacePool Class

Definition

Public interface which supports pooling PowerShell Runspaces.

public sealed class RunspacePool : IDisposable
type RunspacePool = class
    interface IDisposable
Public NotInheritable Class RunspacePool
Implements IDisposable
Inheritance
RunspacePoolRunspacePoolRunspacePool
Implements

Properties

ApartmentState ApartmentState ApartmentState

ApartmentState of the thread used to execute commands within this RunspacePool

CleanupInterval CleanupInterval CleanupInterval

Specifies how often unused runspaces are disposed.

ConnectionInfo ConnectionInfo ConnectionInfo

Connection information for remote RunspacePools, null for local RunspacePools

InitialSessionState InitialSessionState InitialSessionState

Gets the InitialSessionState object that this pool uses to create the runspaces.

InstanceId InstanceId InstanceId

Get unique id for this instance of runspace pool. It is primarily used for logging purposes.

IsDisposed IsDisposed IsDisposed

Gets a boolean which describes if the runspace pool is disposed.

RunspacePoolAvailability RunspacePoolAvailability RunspacePoolAvailability

Returns runspace pool availability.

RunspacePoolStateInfo RunspacePoolStateInfo RunspacePoolStateInfo

Gets State of the current runspace pool.

ThreadOptions ThreadOptions ThreadOptions

This property determines whether a new thread is created for each invocation

Methods

BeginClose(AsyncCallback, Object) BeginClose(AsyncCallback, Object) BeginClose(AsyncCallback, Object)

Closes the RunspacePool asynchronously and cleans all the internal resources. This will close all the runspaces in the runspacepool and release all the async operations waiting for a runspace. If the pool is already closed or broken or closing this will just return.

BeginConnect(AsyncCallback, Object) BeginConnect(AsyncCallback, Object) BeginConnect(AsyncCallback, Object)

Connects the runspace pool asynchronously. Runspace pool must be in disconnected state.

BeginDisconnect(AsyncCallback, Object) BeginDisconnect(AsyncCallback, Object) BeginDisconnect(AsyncCallback, Object)

Disconnects the runspace pool asynchronously. Runspace pool must be in Opened state.

BeginOpen(AsyncCallback, Object) BeginOpen(AsyncCallback, Object) BeginOpen(AsyncCallback, Object)

Opens the RunspacePool asynchronously. RunspacePool must be opened before it can be used. To get the exceptions that might have occurred, call EndOpen.

Close() Close() Close()

Closes the RunspacePool and cleans all the internal resources. This will close all the runspaces in the runspacepool and release all the async operations waiting for a runspace. If the pool is already closed or broken or closing this will just return.

Connect() Connect() Connect()

Connects the runspace pool synchronously. Runspace pool must be in disconnected state.

CreateDisconnectedPowerShells() CreateDisconnectedPowerShells() CreateDisconnectedPowerShells()

Creates an array of PowerShell objects that are in the Disconnected state for all currently disconnected running commands associated with this runspace pool.

Disconnect() Disconnect() Disconnect()

Disconnects the runspace pool synchronously. Runspace pool must be in Opened state.

Dispose() Dispose() Dispose()

Dispose the current runspacepool.

EndClose(IAsyncResult) EndClose(IAsyncResult) EndClose(IAsyncResult)

Waits for the pending asynchronous BeginClose to complete.

EndConnect(IAsyncResult) EndConnect(IAsyncResult) EndConnect(IAsyncResult)

Waits for the pending asynchronous BeginConnect to complete.

EndDisconnect(IAsyncResult) EndDisconnect(IAsyncResult) EndDisconnect(IAsyncResult)

Waits for the pending asynchronous BeginDisconnect to complete.

EndOpen(IAsyncResult) EndOpen(IAsyncResult) EndOpen(IAsyncResult)

Waits for the pending asynchronous BeginOpen to complete.

GetApplicationPrivateData() GetApplicationPrivateData() GetApplicationPrivateData()

Private data to be used by applications built on top of PowerShell.

Local runspace pool is created with application private data set to an empty PSPrimitiveDictionary.

Remote runspace pool gets its application private data from the server (when creating the remote runspace pool) Calling this method on a remote runspace pool will block until the data is received from the server. The server will send application private data before reaching Opened state.

Runspaces that are part of a RunspacePool inherit application private data from the pool.

GetAvailableRunspaces() GetAvailableRunspaces() GetAvailableRunspaces()

Retrieves the number of runspaces available at the time of calling this method.

GetCapabilities() GetCapabilities() GetCapabilities()

Returns RunspacePool capabilities.

GetMaxRunspaces() GetMaxRunspaces() GetMaxRunspaces()

Retrieves the maximum number of runspaces the pool maintains.

GetMinRunspaces() GetMinRunspaces() GetMinRunspaces()

Retrieves the minimum number of runspaces the pool maintains.

GetRunspacePools(RunspaceConnectionInfo) GetRunspacePools(RunspaceConnectionInfo) GetRunspacePools(RunspaceConnectionInfo)

Queries the server for disconnected runspace pools and creates an array of runspace pool objects associated with each disconnected runspace pool on the server. Each runspace pool object in the returned array is in the Disconnected state and can be connected to the server by calling the Connect() method on the runspace pool.

GetRunspacePools(RunspaceConnectionInfo, PSHost) GetRunspacePools(RunspaceConnectionInfo, PSHost) GetRunspacePools(RunspaceConnectionInfo, PSHost)

Queries the server for disconnected runspace pools and creates an array of runspace pool objects associated with each disconnected runspace pool on the server. Each runspace pool object in the returned array is in the Disconnected state and can be connected to the server by calling the Connect() method on the runspace pool.

GetRunspacePools(RunspaceConnectionInfo, PSHost, TypeTable) GetRunspacePools(RunspaceConnectionInfo, PSHost, TypeTable) GetRunspacePools(RunspaceConnectionInfo, PSHost, TypeTable)

Queries the server for disconnected runspace pools and creates an array of runspace pool objects associated with each disconnected runspace pool on the server. Each runspace pool object in the returned array is in the Disconnected state and can be connected to the server by calling the Connect() method on the runspace pool.

Open() Open() Open()

Opens the runspacepool synchronously. RunspacePool must be opened before it can be used.

SetMaxRunspaces(Int32) SetMaxRunspaces(Int32) SetMaxRunspaces(Int32)

Sets the maximum number of Runspaces that can be active concurrently in the pool. All requests above that number remain queued until runspaces become available.

SetMinRunspaces(Int32) SetMinRunspaces(Int32) SetMinRunspaces(Int32)

Sets the minimum number of Runspaces that the pool maintains in anticipation of new requests.

Events

StateChanged StateChanged StateChanged

Event raised when RunspacePoolState changes.

Applies to