Sorry my english is not well,but I try my best to explain the problem.
I use BackgroundWorker control SerialPort to read and write data.
When I use VS 2008 to run the program, everything is fine,
but, if run excution file(.exe), the program is no response.
How to fix the problem?
/* BackgroundWorker DoWork event */ this.Invoke(this.delegateOutputLaserStatus, new object[] { "ProgramID " + lSubProgramID + " SN transmit.." }); // use SerialPort send command mLaserControl.changeSN(LaserControl.mProgramID, Int32.Parse(lSubProgramID), pSN); // wait SerialPort get all response while (!mLaserControl.mGetData) { } // reset Flag to false mLaserControl.mGetData = false; mLaserControl.mReturnData = "";/* SerialPort DataReceive event */ byte[] lReadData = new byte[lBytesToRead]; // read data mLaserSerialPort.Read(lReadData, 0, lBytesToRead); mReturnData += Encoding.ASCII.GetString(lReadData); // if not end byte then return if (lReadData[lBytesToRead - 1] != mSeperateCommand[0]) return; // set Flag to true when read all data if (mReadData != "") { mGetData = true; }