Dela via


RunspacePool Class

Definition

Public interface which supports pooling PowerShell Runspaces.

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

Properties

ApartmentState

ApartmentState of the thread used to execute commands within this RunspacePool.

CleanupInterval

Specifies how often unused runspaces are disposed.

ConnectionInfo

Connection information for remote RunspacePools, null for local RunspacePools.

InitialSessionState

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

InstanceId

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

IsDisposed

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

RunspacePoolAvailability

Returns runspace pool availability.

RunspacePoolStateInfo

Gets State of the current runspace pool.

ThreadOptions

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

Methods

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)

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

BeginDisconnect(AsyncCallback, Object)

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

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()

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()

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

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()

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

Dispose()

Dispose the current runspacepool.

EndClose(IAsyncResult)

Waits for the pending asynchronous BeginClose to complete.

EndConnect(IAsyncResult)

Waits for the pending asynchronous BeginConnect to complete.

EndDisconnect(IAsyncResult)

Waits for the pending asynchronous BeginDisconnect to complete.

EndOpen(IAsyncResult)

Waits for the pending asynchronous BeginOpen to complete.

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()

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

GetCapabilities()

Returns RunspacePool capabilities.

GetMaxRunspaces()

Retrieves the maximum number of runspaces the pool maintains.

GetMinRunspaces()

Retrieves the minimum number of runspaces the pool maintains.

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.

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)

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()

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

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)

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

Events

StateChanged

Event raised when RunspacePoolState changes.

Applies to