Beispiel #1
0
        public ContentionInfo GetContentionInfo(int threadId)
        {
            ContentionInfo contentionInfo;

            if (!_perThreadContentionInfo.TryGetValue(threadId, out contentionInfo))
            {
                contentionInfo = new ContentionInfo(_processId, threadId);
                _perThreadContentionInfo.Add(threadId, contentionInfo);
            }
            return(contentionInfo);
        }
        private void OnContentionStart(ContentionTraceData data)
        {
            ContentionInfo info = _contentionStore.GetContentionInfo(data.ProcessID, data.ThreadID);

            if (info == null)
            {
                return;
            }

            info.TimeStamp = data.TimeStamp;
            info.ContentionStartRelativeMSec = data.TimeStampRelativeMSec;
        }
        private void OnContentionStop(ContentionTraceData data)
        {
            ContentionInfo info = _contentionStore.GetContentionInfo(data.ProcessID, data.ThreadID);

            if (info == null)
            {
                return;
            }

            // unlucky case when we start to listen just after the ContentionStart event
            if (info.ContentionStartRelativeMSec == 0)
            {
                return;
            }

            var contentionDurationMSec = data.TimeStampRelativeMSec - info.ContentionStartRelativeMSec;
            var isManaged = (data.ContentionFlags == ContentionFlags.Managed);

            NotifyContention(data.TimeStamp, data.ProcessID, data.ThreadID, TimeSpan.FromMilliseconds(contentionDurationMSec), isManaged);
        }