是什么导致WPF应用程序因AppHangB1问题事件名称而崩溃? [英] What can cause a WPF application to crash with an AppHangB1 Problem Event Name?

查看:515
本文介绍了是什么导致WPF应用程序因AppHangB1问题事件名称而崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用的程序偶尔会因AppHangB1问题事件而挂起。我已经将其追溯到一系列特定的操作,但是它似乎是一种heisenbug,因为每当我逐步执行代码时,它就不会显现出来。程序挂起后,我无法暂停程序以查看它在Visual Studio中的挂起位置。此应用程序中发生了很多事情(非托管互操作,多线程等),因此在我的特定应用程序中可能有许多错误。

The program I'm currently working on occasionally hangs with an AppHangB1 problem event. I have traced it to a specific series of actions, but it seems to be a type of heisenbug, as whenever I step through the code, it doesn't manifest itself. And once the program hangs, I can't pause the program to see where it is hung in Visual Studio. There are many things going on in this application (unmanaged interop, multi-threading, etc.), so it could be any number of things that are wrong in my particular application.

我不是在寻找任何人为我解决问题,我只是想知道哪种类型的事情会导致这种情况?我在Google上找到了几笔热门广告,但没有任何帮助。 .NET应用程序的任何调试技巧(可能有助于查明问题)也将有所帮助。

I am not looking for anyone to solve my problem for me, I'm just wondering what types of things could cause this type of hang? I found a couple hits on Google, but nothing that helped. Any debugging tricks for .NET applications that could help pinpoint the problem would also help.

推荐答案

UI触发AppHangB1事件线程几秒钟没有响应消息,用户尝试终止它。挂起可能是由几乎所有原因引起的:代码中的繁忙循环,在UI线程上执行网络或磁盘I / O,UI线程被执行长时间运行任务的后台线程持有的锁阻塞,等等。

The AppHangB1 event is triggered when the UI thread doesn't respond to messages for several seconds and the user tries to terminate it. Hangs can be caused by just about anything: busy loops in your code, doing network or disk I/O on the UI thread, the UI thread being blocked on a lock held by a background thread doing a long running task, etc.

这有点关系到Visual Studio在挂起时无法中断。您要附加仅托管调试还是混合模式调试?您可以尝试使用Windbg( http://www.microsoft.com/whdc/devtools /debugging/default.mspx )以非侵入方式连接到进程,并尝试获取挂起线程的堆栈跟踪(您想看看使用!clrstack来获取托管堆栈跟踪)。 Windbg的学习曲线非常陡峭,因此您可能只想收集一个可在Visual Studio中调试的转储。

It's a bit concerning that Visual Studio can't break at the point of the hang. Are you attaching for managed-only debugging or for mixed-mode debugging? You could try using Windbg (http://www.microsoft.com/whdc/devtools/debugging/default.mspx) to non-invasively attach to the process and try to get a stack trace of the hung thread (you want to look at using !clrstack to get the managed stack trace). The learning curve for Windbg is pretty steep, so you might just want to collect a dump that you can debug in Visual Studio.

这篇关于是什么导致WPF应用程序因AppHangB1问题事件名称而崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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