SimpleLogger.SimpleLog.Flush C# (CSharp) Method

Flush() public static method

Wait for all entries having been written to the file
public static Flush ( ) : void
return void
        public static void Flush()
        {
            // Background task not running? Nothing to do.
            if(!LoggingStarted)
                return;

            // Are there still items waiting to be written to disk?
            while(NumberOfLogEntriesWaitingToBeWrittenToFile > 0)
            {
                // Remember current number
                int lastNumber = NumberOfLogEntriesWaitingToBeWrittenToFile;

                // Wait some time to let background task do its work
                Thread.Sleep(222);

                // Didn't help? No log entries have been processed? We probably hang.
                // Let it be to avoid waiting eternally.
                if(lastNumber == NumberOfLogEntriesWaitingToBeWrittenToFile)
                    break;
            }
        }