예제 #1
0
        public void WriteAsyn(MvLoggerEventArgs ea)
        {
            this.msgQueue.Enqueue(ea);

            lock (this)
            {
                if (this.Task != null)
                {
                    if (this.Task.IsEnd())
                    {
                        using (var obj = this.Task)
                            obj.Cancel();
                    }
                    else
                    {
                        return;
                    }
                }

                this.Task = MvCancelTask.RunLoop(() =>
                {
                    MvSpinWait.SpinUntil(() => this.msgQueue.Count > 0);

                    MvLoggerEventArgs eaLog;
                    if (!this.msgQueue.TryDequeue(out eaLog))
                    {
                        return(true);
                    }
                    this.WriteSyn(eaLog);
                    return(true);
                });
            }
        }
예제 #2
0
 static void OnEveryLogWrite(object sender, MvLoggerEventArgs ea)
 {
     if (EhEveryLogWrite == null)
     {
         return;
     }
     EhEveryLogWrite(sender, ea);
 }
예제 #3
0
 void OnLogWrite(MvLoggerEventArgs ea)
 {
     if (this.EhLogWrite == null)
     {
         return;
     }
     this.EhLogWrite(this, ea);
 }
예제 #4
0
 public void WriteSyn(MvLoggerEventArgs ea)
 {
     this.OnLogWrite(ea);
     OnEveryLogWrite(this, ea);
 }
예제 #5
0
 public void Write(MvLoggerEventArgs ea, MvLoggerEnumLevel _level = MvLoggerEnumLevel.Info)
 {
     ea.Level = _level;
     this.WriteAsyn(ea);
 }
예제 #6
0
 /// <summary>
 /// 預設寫Log是用非同步
 /// </summary>
 /// <param name="ea"></param>
 public void Write(MvLoggerEventArgs ea)
 {
     this.WriteAsyn(ea);
 }