?
Solved

timer vs backgroundworker device input

Posted on 2010-11-25
2
Medium Priority
?
783 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 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