Exemplo n.º 1
0
        /// <summary>
        /// Called when [work].
        /// </summary>
        protected override void OnWork()
        {
            try
            {
                var threadArray = (ThreadWatcherInfo[])null;
                lock (_threads)
                {
                    threadArray = _threads.ToArray();
                }

                if (threadArray.Length == 0)
                {
                    return;
                }

                for (var i = 0; i < threadArray.Length; i++)
                {
                    if (DateTime.Now.Subtract(threadArray[i].LastResponseTime) > threadArray[i].MaxAliveWindow)
                    {
                        if (_workManager != null)
                        {
                            _workManager.RemoveNonResponsiveWorker(threadArray[i]);
                        }

                        lock (_threads)
                        {
                            _threads.Remove(threadArray[i]);
                        }
                    }
                }

                PassiveSleep(_workSleep);
            }
            catch (Exception ex)
            {
                Notification.SendException(ex, true);
            }
        }