static void SendLogic() { try { using (var client = new TcpClient("data.logentries.com", 80)) { client.NoDelay = true; using (var stream = client.GetStream()) using (var writer = new StreamWriter(stream)) { foreach (var str in LogQueue.GetConsumingEnumerable()) { writer.WriteLine(string.Format("{0} [{1}] {2}", TokenKey, DeviceName, str)); writer.Flush(); } } } } catch { Thread.Sleep(5000); SendLogic(); } }