Cmdlet.EndProcessing 和 Cmdlet.StopProcessing 之间的区别

发布于 2024-08-09 20:48:41 字数 502 浏览 11 评论 0原文

编写 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2024-08-16 20:48:41

如果取消 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文