A comment about your Log(string) method. The lock
keyword is just syntactic sugar for a call to the Monitor
class. See here. Here is what lock
becomes:
bool lockWasTaken = false;var temp = obj;try { Monitor.Enter(temp, ref lockWasTaken); { //body } }finally { if (lockWasTaken) Monitor.Exit(temp); }
So your Log(string) method is actually this:
public static void Log(string logMessage){ try { bool lockWasTaken = false; var temp = _syncObject; try { Monitor.Enter(temp, ref lockWasTaken); { _buffer.Add(logMessage); Save(_buffer); } } finally { if (lockWasTaken) Monitor.Exit(temp); } } catch (Exception ex) { throw; }}
Did you put in your catch and throw statement because you were worried that a possible exception will get eaten somewhere? You can see from this that that's not the case.