Solved

timer vs backgroundworker device input

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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