Solved

timer vs backgroundworker device input

Posted on 2010-11-25
2
781 Views
Last Modified: 2012-05-10
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!


0
Comment
Question by:codefinger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 11

Expert Comment

by:bansidhar
ID: 34215398
from your explanation it looks like the function GetUserDeviceInput(30) is a blocking one. You will have to call this in a separate thread.
0
 
LVL 11

Accepted Solution

by:
bansidhar earned 500 total points
ID: 34215405
You will need a timer and a background worker for GetUserDeviceInput(30). putting the timer in the background worker will give you the same result. Only the ui will be responsive.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question