相关疑难解决方法(0)

什么会使PerformanceCounterCategory.Exists无限期挂起?

我有一个使用性能计数器的应用程序,已经工作了几个月.现在,在我的开发机器和另一台开发人员机器上,当我调用PerformanceCounterCategory.Exists时它已经开始挂起.据我所知,它无限期地挂起.我使用哪个类别作为输入并不重要,使用API​​的其他应用程序表现出相同的行为.

调试(使用MS Symbol Servers)显示它是对挂起的Microsoft.Win32.RegistryKey的调用.进一步的调查表明,这条线是挂起的:

while (Win32Native.ERROR_MORE_DATA == (r = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref sizeInput))) { 
Run Code Online (Sandbox Code Playgroud)

这基本上是一个尝试为性能计数器数据分配足够内存的循环.它开始于size = 65000并进行一些迭代.在第4次通话中size = 520000,Win32Native.RegQueryValueEx挂起时.

此外,相当令人担忧的是,我在PerformanceCounterLib.GetData的参考源中找到了这条评论:

    // Win32 RegQueryValueEx for perf data could deadlock (for a Mutex) up to 2mins in some 
    // scenarios before they detect it and exit gracefully. In the mean time, ERROR_BUSY,
    // ERROR_NOT_READY etc can be seen by other concurrent calls (which is the reason for the 
    // wait loop and …
Run Code Online (Sandbox Code Playgroud)

.net c# debugging performancecounter

39
推荐指数
1
解决办法
4778
查看次数

标签 统计

.net ×1

c# ×1

debugging ×1

performancecounter ×1