我有一个自定义 dll,现在在我的多线程代码中,我通过以下方式引用此 dll:
……
$threads = 6
for ($i2 = 0; $i2 -lt $threads)
{
Copy-Item myCmdlet.dll $i2.dll
$i2++
}
for ($i = 0; $i -lt $threads)
{
$jobs += Start-job -ScriptBlock $ScriptBlock -ArgumentList ($i)
}
……
$ScriptBlock = {
param($i)
Installutil $i.dll
Get-PSSnapIn -Registered
Add-PSSnapIn MyCmdletSet
$result = Get-MyCmdlet
....
}
……
这会很烦人,因为我最终可能会得到许多原始 dll 的副本。在多线程机制中调用dll还有其他方法吗?
感谢所有答案!