TestimoX

API Reference

Class

RunspacePool

Namespace TestimoX.PowerShell
Assembly TestimoX
Implements
IDisposable

Lightweight runspace pool with optional leak detection.

Inheritance

  • Object
  • RunspacePool

Remarks

The pool reuses runspaces to reduce the overhead of creating new ones on every PowerShell invocation.

Usage

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by

Accepted by parameters

Examples


using var pool = new RunspacePool();
Runspace rs = pool.Acquire();
// use runspace
pool.Release(rs);
        

Constructors

public RunspacePool(Boolean leakDetection = false, Nullable<Int32> maxPoolSize = null) #

Creates a new runspace pool.

Parameters

leakDetection System.Boolean = false optionalposition: 0
Enable optional leak tracking.
maxPoolSize System.Nullable{System.Int32} = null optionalposition: 1
Maximum idle runspaces to retain.

Methods

public Runspace Acquire() #
Returns: Runspace

Gets a runspace from the pool or creates a new one if none are available.

public virtual Void Dispose() #
Returns: Void

Disposes all idle runspaces in the pool.

public Void Release(Runspace runspace) #
Returns: Void

Returns a runspace to the pool. Disposes it if the pool is full or the runspace is closed.

Parameters

runspace System.Management.Automation.Runspaces.Runspace requiredposition: 0

Properties

public Int32 MaxPoolSize { get; } #

Maximum number of idle runspaces kept in the pool.

public Int32 IdleCount { get; } #

Approximate number of idle runspaces (diagnostic only).

public Int32 InUseCount { get; } #

Number of runspaces currently in use.