S
Simon
Hi all,
I'm writing a PocketPC / CE application which communicates with a
Bluetooth GPS reciever that is paired to a serial port but I'm
experiencing odd behaviour from the CF 2.0 SerialPort class.
Everything is fine first time around, but if I quit my application and
restart a few times, pretty soon (usuaully the second or third
restart) the DataReceived event stops firing on the SerialPort object.
I'm connecting with this code:-
_comPort = new SerialPort(comPortName, comBaud, comParity,
comDataBits, comStopBits);
_comPort.Encoding = Encoding.ASCII;
_comPort.Handshake = comHandshake;
_comPort.ReceivedBytesThreshold = 1;
_comPort.DataReceived += new
SerialDataReceivedEventHandler(DataReceived);
_comPort.Open();
My DataReceived handler contains the following code:-
string newData = _comPort.ReadExisting();
When the app exits, I'm disconnecting / closing with:-
if (_comPort != null)
{
if (_comPort.IsOpen) _comPort.Close();
_comPort.Dispose();
_comPort = null;
}
Everything works fine on the first run, but after a couple of restarts
DataReceived stops firing. Any ideas?
Many TIA,
Simon
I'm writing a PocketPC / CE application which communicates with a
Bluetooth GPS reciever that is paired to a serial port but I'm
experiencing odd behaviour from the CF 2.0 SerialPort class.
Everything is fine first time around, but if I quit my application and
restart a few times, pretty soon (usuaully the second or third
restart) the DataReceived event stops firing on the SerialPort object.
I'm connecting with this code:-
_comPort = new SerialPort(comPortName, comBaud, comParity,
comDataBits, comStopBits);
_comPort.Encoding = Encoding.ASCII;
_comPort.Handshake = comHandshake;
_comPort.ReceivedBytesThreshold = 1;
_comPort.DataReceived += new
SerialDataReceivedEventHandler(DataReceived);
_comPort.Open();
My DataReceived handler contains the following code:-
string newData = _comPort.ReadExisting();
When the app exits, I'm disconnecting / closing with:-
if (_comPort != null)
{
if (_comPort.IsOpen) _comPort.Close();
_comPort.Dispose();
_comPort = null;
}
Everything works fine on the first run, but after a couple of restarts
DataReceived stops firing. Any ideas?
Many TIA,
Simon