static void send() { LogDetails log; while (true) { while (buffer.isEmpty()) { Thread.Sleep(50); } log = buffer.read(); //myResetEvent.WaitOne(); string strLog = ""; if (0 == log.type) { strLog = Encoding.Default.GetString(log.txt); } else if (log.type == 1) { strLog += "TX:"; for (int i = 0; i < log.length; i++) { strLog += log.txt[i].ToString("X2") + " "; } } else if (log.type == 2) { strLog += "RX:"; for (int i = 0; i < log.length; i++) { strLog += log.txt[i].ToString("X2") + " "; } } else if (log.type == 3) { strLog = log.strTxt; } strLog += "\r\n"; notifyResetEvent.WaitOne(); mHandle.BeginInvoke(strLog, null, null); //myResetEvent.Set(); } }