Example #1
0
        internal static void AddEventCounter(EventSource eventSource, EventCounter eventCounter)
        {
            int eventSourceIndex = EventListenerHelper.EventSourceIndex(eventSource);

            EventCounterGroup.EnsureEventSourceIndexAvailable(eventSourceIndex);
            EventCounterGroup eventCounterGroup = GetEventCounterGroup(eventSource);

            eventCounterGroup.Add(eventCounter);
        }
Example #2
0
        private static EventCounterGroup GetEventCounterGroup(EventSource eventSource)
        {
            int eventSourceIndex     = EventListenerHelper.EventSourceIndex(eventSource);
            EventCounterGroup result = EventCounterGroup.s_eventCounterGroups[eventSourceIndex];

            if (result == null)
            {
                result = new EventCounterGroup(eventSource, eventSourceIndex);
                EventCounterGroup.s_eventCounterGroups[eventSourceIndex] = result;
            }

            return(result);
        }
Example #3
0
 internal static EventCounterGroup GetEventCounterGroup(EventSource eventSource)
 {
     lock (s_eventCounterGroupsLock)
     {
         int eventSourceIndex = EventListenerHelper.EventSourceIndex(eventSource);
         EnsureEventSourceIndexAvailable(eventSourceIndex);
         WeakReference <EventCounterGroup> weakRef = EventCounterGroup.s_eventCounterGroups[eventSourceIndex];
         EventCounterGroup ret = null;
         if (weakRef == null || !weakRef.TryGetTarget(out ret))
         {
             ret = new EventCounterGroup(eventSource);
             EventCounterGroup.s_eventCounterGroups[eventSourceIndex] = new WeakReference <EventCounterGroup>(ret);
         }
         return(ret);
     }
 }