Cmdlet.EndProcessing 和 Cmdlet.StopProcessing 之间的区别
编写 Powershell cmdlet 时,EndProcessing 和 停止处理?它们听起来相同,描述也几乎相同,并且后者不会出现在 cmdlet 生命周期文档。
When writing Powershell cmdlets, what is the difference between EndProcessing and StopProcessing? They sound the same, their descriptions are just about the same, and latter doesn't appear in the cmdlet lifecycle documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果取消 CmdLet 的执行,则调用 StopProcessing(按 CNTRL-C 将导致执行 StopProcessing)。
如果 CmdLet 的执行正常结束,则调用 EndProcessing。
我通常使用 StopProcessing 和 EndProcessing 来做同样的事情...即清理 BeginProcessing 或 ProcessRecord 期间配置的资源,但在某些情况下,每个提供的操作之间存在一些差异。
生命周期文档中没有显示它似乎是一个错误。
StopProcessing is called if the execution of the CmdLet is cancelled (pressing CNTRL-C will cause StopProcessing to be executed).
EndProcessing is called if the execution of the CmdLet ends normally.
I typically use StopProcessing and EndProcessing to do the same thing... that is to clean up resources that were provisioned during BeginProcessing or ProcessRecord, in some cases though there is some difference between what actions each provides.
It seems like a mistake that it is not shown in the life cycle documentation.