BF2Statistics.Logging.LogWriter.FlushLog C# (CSharp) Method

FlushLog() private method

Flushes the Queue to the physical log file
private FlushLog ( ) : void
return void
        private async void FlushLog()
        {
            // Append messages
            using (FileStream fs = LogFile.Open(FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read))
            using (StreamWriter writer = new StreamWriter(fs))
            {
                // if the user requests a truncate, empty the file now before flushing
                if (QueueTruncate)
                {
                    fs.SetLength(0);
                    QueueTruncate = false;
                }
                else // move to end of the stream for appending
                    fs.Seek(0, SeekOrigin.End);

                // write each message on a line
                while (LogQueue.Count > 0)
                {
                    LogMessage entry;
                    if (LogQueue.TryDequeue(out entry))
                        await writer.WriteLineAsync(String.Format("[{0}]\t{1}", entry.LogTime, entry.Message));
                }
            }
        }