Solved

timer vs backgroundworker device input

Posted on 2010-11-25
2
770 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now