public static void StartLogging()
{
// Task already started
if(_backgroundTask != null || StopLoggingRequested)
return;
// Reset stopping flag
StopLoggingRequested = false;
lock(_backgroundTaskSyncRoot)
{
if(_backgroundTask != null)
return;
// Reset last exception
LastExceptionInBackgroundTask = null;
// Create and start task
_backgroundTask = new Task(WriteLogEntriesToFile, TaskCreationOptions.LongRunning);
_backgroundTask.Start();
}
}