Ignore Keystrokes/Shortcuts after initial press

G

garygeorge

Hello,

I have a program that takes a series of pictures after a key is
pressed (basically a photo booth type thing). I am using a button
that is sends a F9 keystroke when pressed. I am then using the
shortcut on a menu to trigger the code to execute. The problem is
that if someone presses it multiple times at the begining it queues up
the request and restarts the process until all of the button presses
have been processed. I have tried to disable and re-enable the
shortcut. I have also tried to set a variable that it should be
ignored if it is currently processing.

I think it might be able to be solved by threading, but I am not sure
how I would do that. Any help is appreciated.

Thanks,
Gary
 
J

james

Only surefire way is to use a lock. Try code like this

void onClick()
{
lock(this)
{
//execute code here
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top