private static void InitSharedPool() { if (_sharedRunspacePool == null) { _sharedRunspacePool = new OnDisposable <RunspacePool>(RunspaceFactory.CreateRunspacePool()); _sharedRunspacePool.Value.Open(); } }
public DynamicPowershell(OnDisposable <RunspacePool> pool = null) { if (pool == null) { InitSharedPool(); pool = _sharedRunspacePool; } _runspacePool = pool; Reset(); RefreshCommandList(); }
public void Dispose() { _runspacePool = null; // will call dispose if this is the last instance using it. }