Пример #1
0
        private void LazyWriterTimerCallback(object state)
        {
            lock (_inLazyWriterMonitor)
            {
                try
                {
                    do
                    {
                        // Console.WriteLine("q: {0}", RequestQueue.RequestCount);
                        List <LogEventInfo> pendingRequests = RequestQueue.DequeueBatch(BatchSize);

                        try
                        {
                            if (pendingRequests.Count == 0)
                            {
                                break;
                            }

                            LogEventInfo[] events = pendingRequests.ToArray();
                            WrappedTarget.Write(events);
                        }
                        finally
                        {
                            RequestQueue.BatchProcessed(pendingRequests);
                        }
                    } while (_flushAll);
                }
                catch (Exception ex)
                {
                    InternalLogger.Error("Error in lazy writer timer procedure: {0}", ex);
                }
            }
        }