I am trying to add support for custom features to a piece of software. The code for these features is using a sdk from a third party driver (wacom driver for tablet devices). The software I am working on is very large, and I have noticed the previous programmers have chosen to send a lot of windows messages back in forth, instead say using a function call instead. So there are periods in the software where a lot of processing is going where the windows message queue is getting extremely backed up.
Now, the way the hardware works is that it sends packets whenever an event occurs (pen touched screen, button was pressed, etc). The hardware will also send a windows message upon packet arrival (this is how my code will know when to process packets and then flush them from the queue). So as you can guess, what is happening is a buffer overflow sitation in which packets are being sent, but are not properly flushed from the queue because the windows message associated with them is backed up in the windows message queue and is not reaching the code in time. I have already increased the packet buffer size to its limit.
So, this code is large, redesign is not possible. That leaves other options on the table. I have considered in the past making the class responsible for packet handling a user interface thread and setting up a separate message queue for handling packets but this did not work real well. I am open for advice at this point on what to do.