I have an app which gets data from a network and waits for Ondata events. Each Ondata event passes a buffer of data which I then process. Problem is when the data arrives very fast the Ondata event is retriggered as soon as the proc for the last one finishes - so the app "locks up" because no other events are processed.
So, I thought, lets put the processing in a thread so it can process as fast as it can, but still give control back to the user window. That works EXCEPT that the thread consumes windows system & user resource as it goes - presumably because the threads message queue is filling?? If I suspend the thread for a few seconds and then resume it all the windows resources are restored but then start being eaten again. If I "throttle back" the machine which is delivering the data then there is no problem at all.
So my question is: How can I process the message queue (main window or thread) without processing the Ondata event until all the others are deailt with. So the flow would be:
1. Start data get
2. Wait for Ondata event and process data
3. Check for other messages and process them
4. Wait for next Ondata event & process data
5. Back to 3.
I have given this a "hard" rating - it's driving me nuts! Hopefully it will be "easy" for someone out there.