Ejemplo n.º 1
0
        /// <summary>
        /// Logging queue processing run function
        /// </summary>
        private async Task RunLogging(CancellationToken cancelToken)
        {
            try
            {
                while (!cancelToken.IsCancellationRequested)
                {
                    await NotifyAddedLog.WaitAsync(cancelToken);

                    List <LogEventArgs> allEvents = new List <LogEventArgs>();
                    while (!LogsQueue.IsEmpty)
                    {
                        if (LogsQueue.TryDequeue(out var nextLog))
                        {
                            allEvents.AddRange(GenerateLogsForLogEvent(nextLog));
                        }
                    }

                    LoggedEvents?.Invoke(this, allEvents);

                    LogToLog4(allEvents);
                }
            }
            catch (OperationCanceledException)
            { }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine($"Exception in logging: {e}.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Logging queue processing run function
        /// </summary>
        async Task RunLogging(CancellationToken cancelToken)
        {
            try
            {
                try
                {
                    while (!cancelToken.IsCancellationRequested)
                    {
                        await NotifyAddedLog.WaitAsync(cancelToken);

                        ProcessLogs();
                    }
                }
                catch (OperationCanceledException)
                { }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine($"Exception in logging: {e}.");
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine($"Exception in logging: {e}.");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Add a log to the logging queue
 /// </summary>
 public void AddLog(LogEventArgs log)
 {
     LogsQueue.Enqueue(log);
     NotifyAddedLog.Release();
 }