Dispatcher.Invoke()冻结 [英] Dispatcher.Invoke() freeze

查看:68
本文介绍了Dispatcher.Invoke()冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了Dispacther线程的问题,即未调用Delegate.Invoke()且用户界面停止绘制.尤其是在打开并关闭应用程序的新窗口之后,就会出现此问题.

尝试在分发程序冻结并发现所有其他线程(计时器,BackGroundWorkers)正在工作(只是Dispacther.Invoke()不执行)后,将Visual Studio调试器附加到应用程序的实例. /p>

在冻结分派器之前附加了Visual Studio调试器时,该问题不会重现. (可能是由Visual Studio的调试器处理了Dispatcher的错误).

仅当未附加Visual Studio的调试器并且打开和关闭新应用程序的窗口时,才会出现问题.

从任务管理器"和调试诊断"中收集了完整的内存转储,但是该应用程序的实际状态丢失了,因此找不到任何有意义的信息.

需要进一步解决问题的帮助.

Debug Diag或其他工具有帮助吗?如果是,请提供异常代码以配置崩溃规则.

谢谢.

解决方案

Dhruvesh,

这听起来像是您正在产生死锁.我建议调用Dispatcher.BeginInvoke而不是Dispatcher.Invoke.然后,您确定在多线程应用程序中不会产生死锁.


Hi,

I'm facing an issue with Dispacther thread that the Delegate.Invoke() is not called and the User Interface stops painting. This problem occurs particularly after opening and closing a new window of the application.

Tried attaching Visual Studio debugger to the application's instance after the dispatcher freeze and found that all other threads (timers, BackGroundWorkers) are working (just the Dispacther.Invoke() doesn't execute).

When Visual Studio debugger is attached before dispatcher frozen, the problem does not reproduce. (probably Dispatcher's error is handled by VisualStudio's Debugger.).

Problem only occurs when VisualStudio's Debugger isn't attached and a new application's window is opened and closed. 

Collected Full memory dumps from Task Manager and Debug Diag but the actual state of the application is lost so can't find any meaningful information.

Need help with troubleshooting the problem further.

Would Debug Diag or other tools help? if yes, please provide exception code to configure the crash rule.

Thanks.

解决方案

Hi Dhruvesh,

this sounds like you're producing a Deadlock. I would recommend calling Dispatcher.BeginInvoke instead of Dispatcher.Invoke. Then you're sure that you don't produce a deadlock in your multi-threading-application.


这篇关于Dispatcher.Invoke()冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆