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