Detecting application hangs with ActiveX controls in .Net

时间秒杀一切 提交于 2020-01-04 14:19:59

问题


I am working on upgrades to a screen scraping application. We are using an ActiveX control to scrape screens out of an IBM mainframe. The mainframe program often hangs and crashes the ActiveX control causing our application to crash. We don't have access to the mainframe or the ActiveX source code. We are not going to write our own active x control.

What is the bast way to encapsulate an ActiveX control to detect application hangs with the control so we can kill the process and restart with code?

Should I create 2 separate applications? One as a controller that checks on the other and kills/restarts the process when it hangs?

Would they have to be on separate app domains? Is it possible have two programs communicate with each other even if they are on separate app domains?


回答1:


You can start an executable with System.Diagnostics.Process.Start(). This returns a Process object with a Responding property that you can use to check periodically if the process is still active.

You'll need two separate applications to do this though. And the application you're monitoring needs to have a main window because the monitoring works by checking if the application still processes messages from the main-window messagequeue. This is the same way windows knows to add "Not responding" to a window-title



来源:https://stackoverflow.com/questions/59622/detecting-application-hangs-with-activex-controls-in-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!