Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
编写 Powershell cmdlet 时,EndProcessing和StopProcessing有什么区别?它们听起来一样,它们的描述也差不多,而后者并没有出现在cmdlet 生命周期文档中。
如果 CmdLet 的执行被取消,则调用 StopProcessing(按下 CNTRL-C 将导致执行 StopProcessing)。
如果 CmdLet 的执行正常结束,则调用 EndProcessing。
我通常使用 StopProcessing 和 EndProcessing 来做同样的事情......那就是清理在 BeginProcessing 或 ProcessRecord 期间提供的资源,在某些情况下,尽管每个提供的操作之间存在一些差异。
生命周期文档中没有显示它似乎是一个错误。