System.Diagnostics.Process.Exited 事件是否始终触发?
我正在编写一个应用程序,它通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于崩溃的类型 - 有些崩溃将“进程”留在内存中(例如,只是陷入某些永无休止的循环中,或者 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:
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...