c# - 如何测试 wpf gui 线程是否处于事件状态

标签 c# wpf

我有一个模态 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/

相关文章:

wpf - wpf 中的弹出窗口和切换按钮交互

c# - 我可以使用属性来限制 C# 中接口(interface)方法的使用吗?

c# - 如何从 SQL 开放时间数据库查找接下来 (n) 个开放日

c# - Fluent API 首先在 EF Code 中实现零或一到零或一的关系

c# - 将类处理程序限制为内容

wpf - 依赖于其他属性的依赖属性

c# - C# 中的 Javascript 字符串转义问题

c# - 是否可以在 ASP.NET 中保留页面之间的 View 状态?

wpf - 显示两个重叠边框 xaml WP8

c# - 从 XAML 加载 ResourceDictionary 也会将文件加载到内存中