Esempio n. 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);
                });
            }
        }
Esempio n. 2
0
 static void OnEveryLogWrite(object sender, MvLoggerEventArgs ea)
 {
     if (EhEveryLogWrite == null)
     {
         return;
     }
     EhEveryLogWrite(sender, ea);
 }
Esempio n. 3
0
 void OnLogWrite(MvLoggerEventArgs ea)
 {
     if (this.EhLogWrite == null)
     {
         return;
     }
     this.EhLogWrite(this, ea);
 }
Esempio n. 4
0
 public void WriteSyn(MvLoggerEventArgs ea)
 {
     this.OnLogWrite(ea);
     OnEveryLogWrite(this, ea);
 }
Esempio n. 5
0
 public void Write(MvLoggerEventArgs ea, MvLoggerEnumLevel _level = MvLoggerEnumLevel.Info)
 {
     ea.Level = _level;
     this.WriteAsyn(ea);
 }
Esempio n. 6
0
 /// <summary>
 /// 預設寫Log是用非同步
 /// </summary>
 /// <param name="ea"></param>
 public void Write(MvLoggerEventArgs ea)
 {
     this.WriteAsyn(ea);
 }