我试图在一个高级脚本中使用任务延迟.NET函数,但当我试图保持安静时,我发现有奇怪的行为.
[system.threading.tasks.task]::Delay(1000*$seconds)
个
等待$seconds
秒,输出如下:
Result : System.Threading.Tasks.VoidTaskResult
Id : 99
Exception :
Status : RanToCompletion
IsCanceled : False
IsCompleted : True
CreationOptions : None
AsyncState :
IsFaulted : False
AsyncWaitHandle : System.Threading.ManualResetEvent
CompletedSynchronously : False
我不想要那样的yields ,但这些
$null = [system.threading.tasks.task]::Delay(1000*$seconds)
[system.threading.tasks.task]::Delay(1000*$seconds) |out-null
[void]([system.threading.tasks.task]::Delay(1000*$seconds))
立即返回,除非$seconds
很大,因此有最小的延迟.为什么会出现这种情况,以及如何修复?
谢谢.