public static async void Initialize(string directory, string name) { if (!IsRunning) { while (logQueue.Count > 0) { var log = logQueue.Take(); if (log != null && log != "") await logger.Write(log); } if (!Directory.Exists(directory)) Directory.CreateDirectory(directory); if (logger == null) { logger = new FileLog(directory, name); PacketLog.StartLogTask(); } else { logger.Dispose(); logger.SetLogFile(directory, name); } } else { Console.WriteLine("Log Task is still active, please wait a few seconds"); return; } }
public static async void Initialize(string directory, string file) { if (!Directory.Exists(directory)) Directory.CreateDirectory(directory); logger = new FileLog(directory, file); await Task.Delay(1).ContinueWith(async _ => { while (true) { var log = logQueue.Take(); if (log != null) await logger.Write(log); } }); }