Beispiel #1
0
        public ThreadsSummary GetThreadPoolStats()
        {
            var ts = new ThreadsSummary
            {
                ThreadsPrioritiesCounts        = new ConcurrentDictionary <ThreadPriority, int>(),
                PartialMaxWait                 = Thread.VolatileRead(ref _partialMaxWait),
                FreeThreadsAmount              = _freedThreadsValue.Values.Count(isFree => isFree),
                ConcurrentEventsCount          = _concurrentEvents.Count,
                ConcurrentWorkingThreadsAmount = Thread.VolatileRead(ref _currentWorkingThreadsAmount)
            };

            Parallel.ForEach(_threads, thread =>
            {
                ts.ThreadsPrioritiesCounts.AddOrUpdate(thread.Priority, 1, (tp, val) => val + 1);
            });
            return(ts);
        }
Beispiel #2
0
        public ThreadsSummary GetThreadPoolStats()
        {
            var ts = new ThreadsSummary
            {
                ThreadsPrioritiesCounts        = new Dictionary <ThreadPriority, int>(),
                UnstoppableThreadsCount        = _threads.Count(x => x.Unstoppable),
                PartialMaxWait                 = Thread.VolatileRead(ref _partialMaxWait),
                FreeThreadsAmount              = _freedThreadsValue.Values.Count(isFree => isFree),
                ConcurrentEventsCount          = _concurrentEvents.Count,
                ConcurrentWorkingThreadsAmount = _currentWorkingThreadsAmount
            };

            _threads.ForEach(x =>
            {
                if (!ts.ThreadsPrioritiesCounts.Keys.Contains(x.Thread.Priority))
                {
                    ts.ThreadsPrioritiesCounts.Add(x.Thread.Priority, 0);
                }
                ts.ThreadsPrioritiesCounts[x.Thread.Priority] = ts.ThreadsPrioritiesCounts[x.Thread.Priority] + 1;
            });
            return(ts);
        }