static void MonitorStart() { if (monitor == null) { monitor = new Thread(delegate() { while (true) { if (!sending) { string state = IsisSystem.GetMyAddress().ToString() + " " + IsisSystem.NOW(); Console.WriteLine("Get time " + state); Byte[] tosend = Encoding.ASCII.GetBytes(state); try { sender.BeginSend(tosend, tosend.Length, web, new AsyncCallback(OnSend), ss); sending = true; } catch (Exception e) { Console.WriteLine(e.Message); } } Thread.Sleep(5 * 1000); } }); monitor.Name = "Monitor Thread"; monitor.Start(); } else { monitor.Resume(); } Console.WriteLine("Monitor Thread running"); }