Beispiel #1
0
 internal static CounterGroup GetCounterGroup(EventSource eventSource)
 {
     lock (s_counterGroupLock)
     {
         int eventSourceIndex = EventListener.EventSourceIndex(eventSource);
         EnsureEventSourceIndexAvailable(eventSourceIndex);
         Debug.Assert(s_counterGroups != null);
         WeakReference <CounterGroup> weakRef = CounterGroup.s_counterGroups[eventSourceIndex];
         if (weakRef == null || !weakRef.TryGetTarget(out CounterGroup? ret))
         {
             ret = new CounterGroup(eventSource);
             CounterGroup.s_counterGroups[eventSourceIndex] = new WeakReference <CounterGroup>(ret);
         }
         return(ret);
     }
 }