RunspaceFactory.CreateRunspacePool Method (Int32, Int32, InitialSessionState, PSHost)

Creates a runspace pool that specifies minimum and maximum number of opened runspaces, and a custom host and initial session state information that is used by each runspace in the pool. This method is introduced in Windows PowerShell 2.0.


Namespace: System.Management.Automation.Runspaces
Assembly: System.Management.Automation (in System.Management.Automation.dll)

'Usage
Dim minRunspaces As Integer
Dim maxRunspaces As Integer
Dim initialSessionState As InitialSessionState
Dim host As PSHost
Dim returnValue As RunspacePool

returnValue = RunspaceFactory.CreateRunspacePool(minRunspaces, maxRunspaces, initialSessionState, host)

[SuppressMessageAttribute("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Runspace")] 
[SuppressMessageAttribute("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Runspaces")] 
public static RunspacePool CreateRunspacePool (
	int minRunspaces,
	int maxRunspaces,
	InitialSessionState initialSessionState,
	PSHost host
)
/** @attribute SuppressMessageAttribute("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Runspace") */ 
/** @attribute SuppressMessageAttribute("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Runspaces") */ 
public static RunspacePool CreateRunspacePool (
	int minRunspaces, 
	int maxRunspaces, 
	InitialSessionState initialSessionState, 
	PSHost host
)
SuppressMessageAttribute("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Runspace") 
SuppressMessageAttribute("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Runspaces") 
public static function CreateRunspacePool (
	minRunspaces : int, 
	maxRunspaces : int, 
	initialSessionState : InitialSessionState, 
	host : PSHost
) : RunspacePool

Parameters

minRunspaces

The minimum number of opened runspaces that Windows PowerShell maintains open even if the runspaces are no longer needed (default is one). Typically, Windows PowerShell destroys opened runspaces when they are no longer needed.

maxRunspaces

The maximum number of runspaces that are allowed to be open. Set to a value greater than the minRunspaces parameter.

initialSessionState

An InitialSessionState object that defines the session state configuration when the runspace is opened.

host

A PSHost object that represents the host. A host is needed to interact or communicate directly with the user through prompting.

Return Value

Returns a RunspacePool object that represents the pool with the maximum number of runspaces, the minimum number of runspaces maintained open, and the specified host and initial session state information used when a runspace from the pool is open.

A runspace pool is a set of runspaces that have the same features, such as the same host, initial session state, and connection information. A runspace from the pool is the operating environment used when invoking the commands of a pipeline. After the runspace pool is created, a runspace from the pool must be opened by using one of the following methods before it can be used:

  • To open a runspace from the pool synchronously, call the Open method.

  • To open a runspace from the pool asynchronously, call the BeginOpen method.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

 

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Server 2008, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional, Windows Vista, Windows Server 2003 R2, Windows XP, Windows 7, Windows 2008 R2, Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft