我有一个模态 wpf 应用程序,我需要一种方法来监视应用程序是否仍在工作并且 gui 正在使用其他进程进行响应,我不知道如何完成它。
在其他应用程序上,我只是从主循环中引发一个“事件”事件,但我在 wpf 应用程序中没有任何明确的主循环。
向应用程序添加一个引发事件的调度程序计时器是一个好主意吗?
最佳答案
正在根据要求将我的评论转换为答案。
我认为您正在寻找 Process.Responding
属性。这将返回 UI 是否响应。
注意:Process.Responding
不能与没有 UI 的进程一起使用。
If a process has a user interface, the Responding property contacts the user interface to determine whether the process is responding to user input. If the interface does not respond immediately, the Responding property returns false. Use this property to determine whether the interface of the associated process has stopped responding.
如果进程没有 MainWindowHandle,则此属性返回 true。
有关更多信息,请查看 Process.Responding
关于c# - 如何测试 wpf gui 线程是否处于事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18328143/