SimpleLogger.SimpleLog.StopLogging C# (CSharp) Method

StopLogging() public static method

Stop logging background task, i.e. logging at all.
Stop background task pointing to WriteLogEntriesToFile to write log files to disk.
public static StopLogging ( bool flush = true ) : void
flush bool Whether to write all pending entries to disk before. Default is true.
return void
        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;
            }
        }