Exemple #1
0
        protected override bool Run(object parameters)
        {
            using (TimedLock lck = TimedLock.Lock(_lockObject))
            {
                foreach (ErrorInformation error in _errorList)
                {
                    _processList.Add(error);
                }

                _errorList.Clear();
            }
            try
            {
                // process the list of errors
                for (int i = _processList.Count - 1; i >= 0; i--)
                {
                    ErrorInformation errorInformation = _processList[i];

                    _errorManager.ErrorRaised(errorInformation);

                    _processList.RemoveAt(i);
                }
            }
            finally
            {
                // if there are any items left in the list, add them back to the list
                // for processing next time
                using (TimedLock lck = TimedLock.Lock(_lockObject))
                {
                    foreach (ErrorInformation error in _processList)
                    {
                        _errorList.Add(error);
                    }
                }

                _processList.Clear();
            }

            return(!HasCancelled());
        }