Click here to Skip to main content
15,908,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

This is not easy to describe:
I'm using "port.datareceived += dataReceived" to start processing an incoming data stream from a serial port.
When I want to stop that, I use the "-=" and it works. Problem is that it seems to take some time and that theres is at least one more data sample going through which causes an error due to the processing.

I put a "thread.sleep(500)" behind "port.datareceived -= dataReceived"
But it didn't help.

This also seems to be a windows processing problem, because in some cases it works fine and in some it doesn't.

I hope this makes sense to anyone.

Thanks in advance,

Updated 4-May-12 16:10pm

I would try closing the serial port, removing the handler, and the opening the port again.
Share this answer
I would recommand you to use a background thread for all communications including opening and closing serial port if you want to avoid blocking delays in your UI.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900