public static void StopLogging(bool flush = true)
{
// Tell task to stop.
StopLoggingRequested = true;
if(_backgroundTask == null)
return;
// Write pending entries to disk
if(flush)
Flush();
lock(_backgroundTaskSyncRoot)
{
if(_backgroundTask == null)
return;
// Wait for task to finish and set null then
_backgroundTask.Wait(1000);
_backgroundTask = null;
}
}