whuanle/CZGL.SystemInfo

调用接口/metrics会很大概率出现假死状态

Closed this issue · 1 comments

1.问题1:_process.Refresh(); //这里会出现阻塞

2.问题2:
` public static async Task BuildMetric(ProcessMetricsCore processMetricsCore)
{
if (ListenerPayload == null)
{
await Task.CompletedTask;
return;
}

        try
        {
            _lock.EnterWriteLock(); //<span style="color:red;font-weight:bold">**这里会出现锁异常**</span>
            await Task.Factory.StartNew(() =>
            {
                for (int i = 0; i < ListenerPayload.Count; ++i)
                {
                    if (ListenerPayload[i] is IDictionary<string, object> eventPayload)
                    {
                        GetRelevantMetric(eventPayload, processMetricsCore);
                    }
                }
            });
        }
        catch (Exception ex) { }`

在异步情况下,使用读写锁,并发时会导致出现问题,应该已经修复了