public void Log(LoggerThreshold threshold, string line) { this.doLogging(threshold, () => { this.write(line); }); }
// working method to execute logging in multi threading app protected void doLogging(LoggerThreshold threshold, Action loggingAction) { if (!thresholdReached(threshold)) { return; } mutex.WaitOne(); loggingAction(); mutex.ReleaseMutex(); }
public void Cache(LoggerThreshold threshold, string line) { if (this.logCache == null) { this.logCache = new List <string>(); } if (this.thresholdReached(threshold)) { mutex.WaitOne(); this.logCache.Add(line); mutex.ReleaseMutex(); } }
// test if info needs to get logged protected bool thresholdReached(LoggerThreshold threshold) { return((int)threshold <= (int)this.LogThreshold); }