mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-07-16 00:40:39 +00:00
19 lines
617 B
PowerShell
19 lines
617 B
PowerShell
function Close-WinUtilRunspacePool {
|
|
if ($null -eq $sync -or -not $sync.ContainsKey("runspace") -or $null -eq $sync.runspace) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
if ($sync.runspace.RunspacePoolStateInfo.State -notin @(
|
|
[System.Management.Automation.Runspaces.RunspacePoolState]::Closed,
|
|
[System.Management.Automation.Runspaces.RunspacePoolState]::Closing,
|
|
[System.Management.Automation.Runspaces.RunspacePoolState]::Broken
|
|
)) {
|
|
$sync.runspace.Close()
|
|
}
|
|
} finally {
|
|
$sync.runspace.Dispose()
|
|
$sync.Remove("runspace")
|
|
}
|
|
}
|