System.Diagnostics.Process.Exited 事件是否始终触发?

发布于 2024-12-16 10:39:33 字数 293 浏览 0 评论 0原文

我正在编写一个应用程序,它通过 COM 连接与第三方程序进行通信。我的任务是增强应用程序的弹性,为此我会等到第三方应用程序准备就绪。我通过等待只有在第三方应用程序完全加载时才返回 true 的方法的返回值来执行此操作。

为了避免应用程序在此过程中崩溃的情况,并且我的应用程序只是坐在那里等待抛出 COM 错误(当然捕获),我想知道进程本身的 Exited 事件是否保证总是发生?

如果可能的话,我更愿意提供更多细节。 在当前版本中,我暂时也只能使用 .NET Framework 2.0。

I have an application that I am writting that communicates with a third-party program through a COM connection. I was tasked to strengthen the resilency of our application, in order to do that I wait until the third-party application is ready. I do this by waiting until the return value on a method that returns true only when the third-party application has been fully loaded.

In an effort to avoid the condition where the application crashes during this procedure, and my application just sits there waiting throwing COM errors( caught of course ) I was wondering if the Exited event on the Process itself, is guaranteed to always happen?

I am more then willing to provide additional details when its possible. I am also for the time being limited to .NET Framework 2.0 with this current build.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

很糊涂小朋友 2024-12-23 10:39:33

这取决于崩溃的类型 - 有些崩溃将“进程”留在内存中(例如,只是陷入某些永无休止的循环中,或者 COM 对象打开了一些模式错误对话框并等待用户)...这些情况不包括在内通过您描述中提到的任何方法...

根据我的经验,要真正具有弹性,您需要一个组合:

  • 挂钩 Exited 事件(如果您通过 Process 启动应用程序)或找到
  • 捕获该 COM 对象中任何异常的
  • 进程 ID 和监视器为调用该 COM 实现超时 + 中止逻辑对象/应用程序
  • “监视”COM 对象/应用程序
    我通常在调用这样的 COM 对象之前启动一个单独的线程...该线程监视 COM 对象/应用程序,例如,如果它打开任何不应该的窗口,或者内存消耗在不应该的情况下急剧增加,等等。 -所监视的事物以及对每个事物的反应是特定于该 COM 对象/应用程序的......

It depends on the sort of crash - some crashes leave the "process" in memory (for example just stuck in some never-ending loop OR that COM object opened some modal error dialog and waits for user)... these cases are not covered by any method mentioned in your description...

In my experience to be really resilient you need a combination:

  • hook the Exited event (if you started the application via Process) OR find the process ID and monitor that
  • catch any exceptions from that COM object
  • implement a timeout + abort logic for calls to that COM object/application
  • "monitor" the COM object/app
    I usually start a separate thread before calling such a COM object... that thread monitors the COM object/application for example if it open any window it is not supposed or memory consumption goes through the roof when it is not supposed to etc. - the things monitored and the reaction to each of them is rather specific to that COM object/application...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文