private void SendCommand() { if (waiting == true) { var thread = new Thread(SendCommandWait); thread.IsBackground = true; thread.Start(); return; } dataReceived = false; LogBook.Write("SendCommand, CmdNo: " + curCOMcmd.ToStr()); string sBuf = string.Empty; string[] tempStr; /*Paging commands complete, processing next page.*/ if (curCOMcmd > nCOMcmds || COMcmds[curCOMcmd] == null) { LogBook.Write("Paging commands complete, processing next page."); Message += "\r\nPaging commands complete"; comPort.CloseComPort(); ProcessCompleted = true; return; } sBuf = COMcmds[curCOMcmd]; LogBook.Write("sBuf:" + sBuf); curCOMcmd++; tempStr = sBuf.Split('~'); currentCmd = tempStr[1]; if (currentCmd.Length > 1) { currentCmd = currentCmd + Environment.NewLine; } currentRespTimeout = 0; // Save response timeout value, if specified if (tempStr.Length > 1 & (tempStr[2].IsNumericDecimal()))// || tempStr[2].IsNumericDecimal())) { currentRespTimeout = (int)(tempStr[2].ToDecimal() * 1000); } if (tempStr[0].ToDecimal() > 0) { Thread.Sleep((int)(tempStr[0].ToDecimal() * 1000)); } modemResponse = string.Empty; currentCmdSent = true; /*Close COM port before you send the data, COM port will be automatically opened if it was closed while sending the data.*/ // comPort.CloseComPort(); /*send data using COM port*/ comPort.SerialPortOutput(Encoding.ASCII.GetBytes(currentCmd), false); if (currentRespTimeout > 0) { var waitThread = new Thread(ResponseWait); waitThread.IsBackground = true; waitThread.Start(); } LogBook.Write("Pager COM send: " + currentCmd); //comment//Message += "\r\nPager COM send: " + currentCmd; if (currentCmd.Contains("ATDT")) { aTDTsentTime = DateTime.Now; } //ProcessNextCommand(); //var thread = new Thread(ProcessNextCommand); //thread.IsBackground = true; //thread.Start(); }