Esempio n. 1
0
 /// <summary>
 /// TODO The enqueue.
 /// </summary>
 /// <param name="item">
 /// TODO The item.
 /// </param>
 public new virtual void Enqueue(T item)
 {
     base.Enqueue(item);
     if (this.Count >= this.CapLimit)
     {
         LogEngine.DebugWriteLine($"Log capture limit: {this.CapLimit} > Publish!");
         this.Publish();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// TODO The publish.
        /// </summary>
        protected virtual void Publish()
        {
            var task = new Task(
                () =>
            {
                var itemsToLog = new List <T>();
                try
                {
                    if (this.IsPublishing())
                    {
                        return;
                    }

                    this.StartPublishing();
                    //LogEngine.DebugWriteLine($"Log start dequeue {this.Count} items!");
                    T item;
                    while (this.TryDequeue(out item))
                    {
                        itemsToLog.Add(item);
                    }
                }
                catch (ThreadAbortException tex)
                {
                    LogEngine.DebugWriteLine($"Dequeue items failed > {tex.Message}");

                    LogEngine.WriteLog(
                        Configuration.EngineName,
                        $"Error in {MethodBase.GetCurrentMethod().Name}",
                        Constant.DefconOne,
                        Constant.TaskCategoriesError,
                        tex,
                        EventLogEntryType.Error);
                }
                catch (Exception ex)
                {
                    LogEngine.DebugWriteLine($"Dequeue items failed > {ex.Message}");

                    LogEngine.WriteLog(
                        Configuration.EngineName,
                        $"Error in {MethodBase.GetCurrentMethod().Name}",
                        Constant.DefconOne,
                        Constant.TaskCategoriesError,
                        ex,
                        EventLogEntryType.Error);
                }
                finally
                {
                    //LogEngine.DebugWriteLine($"Log dequeued {itemsToLog.Count} items");
                    this.OnPublish(itemsToLog);
                    this.CompletePublishing();
                }
            });

            task.Start();
        }