I am programming something right now in c#, trying to "convert" a console application to a windows Forms application and I wanted to do something like the following:
if("keypress == nokey")
{
system.threading.thread.sleep ***
}
while(nokeyispressed)
{
system.threading...
}
Basically ask if no key is pressed sleep for some time and this.close();
so that if no key is pressed, do something... I just can't get it to work. I would be very greatful for some help..:D
If no key pressed, then no KeyDown event raised. So, your handler will not be called.
UPDATE (option with loop removed, because timer will make same for you as loop on different thread with sleep timeouts):
Here is sample with timer:
UPDATE: I think good idea to verify how many time elapsed since last key down before decide if no keys were pressed