A
Anton
Hi,
I am new to C# + netcf 2.0sp2 + WinCE 5 and do not understand the problem:
- I use a SerialPort object which reads data with 9600 baud
- on the serial line, the data is arriving continuously
- I have a gui app with a normal timer with 20 ms interval
- the OnTimer function does:
- ask how many bytes are in the receice queue (BytesToRead)
- read all these bytes
What I see:
- In my Visual Studio 2005 SP1 (using ActiveSync over USB) in
the Output window, I can
see that threads are created and exited .. non-stop
(this doesnt come from the timer since no threads are created if
I do not open the serialport)
- after a while the wince device is out of memory :-(
- I did a test: if nothing is incoming on the serial line no threads
are created
It seems that the SerialPort object creates threads for every incoming byte
or whatever.
I increased the Threshold for readind bytes to 10000 but with no effect
(as you see I do a simple polling in the timer).
The same code works on Windows XP without creating thousands of threads.
I remember having read somewhere that WinCE and WinXP handle serial ports
differently (WinCE doesnt have overlapped IO or whatever this means ...).
Can anybody point me out a C# example which works?
Googeling around didn't help until now.
Otherwise I will need to create a C++ dll doing
the stuff, and calling the functions by P/Invoce.
Thanks,
Anton
I am new to C# + netcf 2.0sp2 + WinCE 5 and do not understand the problem:
- I use a SerialPort object which reads data with 9600 baud
- on the serial line, the data is arriving continuously
- I have a gui app with a normal timer with 20 ms interval
- the OnTimer function does:
- ask how many bytes are in the receice queue (BytesToRead)
- read all these bytes
What I see:
- In my Visual Studio 2005 SP1 (using ActiveSync over USB) in
the Output window, I can
see that threads are created and exited .. non-stop
(this doesnt come from the timer since no threads are created if
I do not open the serialport)
- after a while the wince device is out of memory :-(
- I did a test: if nothing is incoming on the serial line no threads
are created
It seems that the SerialPort object creates threads for every incoming byte
or whatever.
I increased the Threshold for readind bytes to 10000 but with no effect
(as you see I do a simple polling in the timer).
The same code works on Windows XP without creating thousands of threads.
I remember having read somewhere that WinCE and WinXP handle serial ports
differently (WinCE doesnt have overlapped IO or whatever this means ...).
Can anybody point me out a C# example which works?
Googeling around didn't help until now.
Otherwise I will need to create a C++ dll doing
the stuff, and calling the functions by P/Invoce.
Thanks,
Anton