private void BackgroundWriter() { while (DoWriting) { string record; bool isEmpty = true; lock (QueueLock) { isEmpty = !LinksQueue.TryDequeue(out record); } if (isEmpty) { Task.Delay(250).Wait(); continue; } Console.WriteLine(record); } }
private void BackgroundWriter() { string record; while (DoWriting) { bool isEmpty = true; lock (QueueLock) { isEmpty = !LinksQueue.TryDequeue(out record); } if (isEmpty) { Task.Delay(250).Wait(); continue; } File.AppendAllLines(this.Path, new string[] { record }); } }