timer vs backgroundworker device input
Posted on 2010-11-25
I have a program for which I want to prompt the user to provide input with a 30 second
time limit. I want the status bar to read...."Program will wait for input for 30 seconds.."
but continue to countdown and update the status bar each second. So each second it waits
it updates the status bar to how much longer it will wait,
reducing the amount by one second. (i.e. "Program will wait for input for 29 more seconds.")
The input the program is waiting for is from a device.
Code is something like: status = GetUserDeviceInput(30)
What ever thread this is called locks that thread either for 30 seconds or until
the user provides the input to the device. By itself, it is NOT an Asynchronous call.
So in this situation, will I need a Timer AND a Background Worker? Will I need to
put my Timer in a background worker? I am not sure how to approach this, since by
definition a timer executes on a separate thread anyway, however, I found that
as soon as status = GetUserDeviceInput(30) is called, the timer event stops updating
the status bar, even though it keeps on ticking.
Application.DoEvents does not help.
What is the best approach to this problem?
Thanks in advance!