I have a form with several buttons on it and when the user presses one of the buttons it begins a lengthy process (takes up to several seconds). What I want to happen is that any subsequent button presses that occur on any other button on the form are ignored until the process is complete from the initial button press. What actually happens is that subsequent button presses go into a queue and are executed in sequence as the processes for each complete. What I mean is, if each button executes a function that takes 2 seconds and I hit 5 buttons very quickly (in less than 2 seconds say) it leads to a sequence of events that takes 10 seconds…. what I want to happen is for it to lead to only the FIRST button press occurring and taking the 2 seconds that it’s activated function takes.
I am writing software that interfaces with hardware through a USB to UART converter and am using virtual COM ports and timing is critical. I want something to occur ONLY when I press a button, not seconds later after being queued up and waiting for a previous operation to finish.
A more difficult, but fruitful, approach is to move the busy work off to a
BackgroundWorkerthread. You will still need to manage controls on your form to limit what a user may do whilst you process earlier requests, but it also allows your form to repaint and handle other events while accomplishing the task at hand.