gpt4 book ai didi

c# - 如何测试 wpf gui 线程是否存活

转载 作者:太空宇宙 更新时间:2023-11-03 10:59:10 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com