在C#应用程序死锁检测 [英] Detecting deadlocks in a C# application

查看:950
本文介绍了在C#应用程序死锁检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
C#/。NET分析工具发现竞争条件/死锁

我调试,我怀疑是越来越僵持和悬挂的应用程序。然而,这仅发生每隔几天,它永远不会发生在我的电脑上,所以我不能挂钩调试器到它。 ?是否有任何实用程序或方法,我可以用它来查询运行的应用程序,并找出方法/锁/不管它是僵持

I am debugging an application that I suspect is getting deadlocked and hanging. However, this only occurs every few days, and it never happens on my computer so I can't hook a debugger up to it. Are there any utilities or methods I can use to query the running application and find out what methods/locks/whatever it is deadlocked on?

更新:通常,应用程序在客户处运行,我没有进入机器,我不完全满意,要求他们安装吨的软件。

Update: Typically the application is running at a customer location and I don't have access to the machine, and I'm not entirely comfortable asking them to install tons of software.

推荐答案

而不是使用常规的锁定&放大器; Monitor.Enter 办法锁定一些数据,你也可以使用TimedLock结构。
这TimedLock抛出一个异常,如果锁不能及时获得,而且还可以给你一个警告,如果你有一些锁,你没有释放。

Instead of using the regular lock & Monitor.Enter approach to lock some data, you can also use a 'TimedLock' structure. This TimedLock throws an exception if the lock couldn't be acquired in a timely fashion, and it can also give you a warning if you have some locks that you didn't release.

这由Ian Griffiths的文章也许可以提供帮助。

This article by Ian Griffiths could maybe help.

这篇关于在C#应用程序死锁检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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