Solved

timer vs backgroundworker device input

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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