473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Timer - temporay pause

I have a program that I need the program to temporarly stop and wait for a
response from a piece of equipment. After a set period I want the program to
continue. Like below

--execute lline before pause
--pause statement- pausefor set period
--execute line after pause

I tried using a timer but the timer messes up my sequence of execution. I
used a do loop that kept checking the current time versus the starting time.
This works but when the loop executes it hogs the CPU. It there a way I can
use a timer to pause, then execute the next line in the program instead of
excuting a function when the timer times out?

Thanks in advance,

Nov 17 '05 #1
2 3385
Dave,

Why not just put the thread to sleep? You can do this through the
static Sleep method on the Thread class.

However, a better design would be to use a event or something like that
and wait until the response comes in (the event would be set on another
thread when the response comes in).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
I have a program that I need the program to temporarly stop and wait for a
response from a piece of equipment. After a set period I want the program
to
continue. Like below

--execute lline before pause
--pause statement- pausefor set period
--execute line after pause

I tried using a timer but the timer messes up my sequence of execution. I
used a do loop that kept checking the current time versus the starting
time.
This works but when the loop executes it hogs the CPU. It there a way I
can
use a timer to pause, then execute the next line in the program instead of
excuting a function when the timer times out?

Thanks in advance,

Nov 17 '05 #2
On Tue, 21 Jun 2005 12:47:55 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Dave,

Why not just put the thread to sleep? You can do this through the
static Sleep method on the Thread class.

However, a better design would be to use a event or something like that
and wait until the response comes in (the event would be set on another
thread when the response comes in).

Hope this helps.


To avoid waiting for too long it might be better to have two events
the second being the expiry of a Thread.Sleep() on a different thread.
The main thread resumes whenever the first of the two events fires.

rossum
The ultimate truth is that there is no ultimate truth
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: William Bub | last post by:
Is there an accurate way to create a "stopwatch" good to 1/10 of a second? I'm not sure if I should use the timer control, or some way to access the computer timer. I found the following site...
0
by: DaveF | last post by:
I am try to download some files from an ftp site asynchronously. I have it on a timer, but if the file gets held up, the timer might cut it off. I need a way to pause the timer and still run the...
2
by: Benjamin | last post by:
Hi, I am having a problem enabling a timer in my class. I have attached some sample pseudo code (see "Sample code illustrating issue") so you can see what I am talking about. Whats the issue?...
3
by: JimJam | last post by:
Hello Peeps I have created a program in VB.NET 2003 that counts down from 7.5 hours to zero from 08:00. I have a button that starts a new countdown from 1 hour to zero whilst the first one is...
17
by: Gaijinco | last post by:
How can I write a program to be executed for a given ammount of time. I mean I want to write a program that once started it doesn't do anything for like 2 minutes and then exits. It is...
3
by: Gordon | last post by:
Hi; I am trying to give my CPU some relief from comparing a group of values to now() while looping through an array. I tried using the windows.system.timer but i have been unable to find the...
0
by: steveyjg | last post by:
I'm trying to call a function that will pause execution for 30 seconds and have a counter timer counting to 30 seconds during this pause. When the counter hits 30 execution of the program will...
5
by: John A. Bailo | last post by:
From a Windows service (NET 2.0) I want to launch serveral threads in a for loop that invokes a method using: new Thread(delegate() { myMethod(248);}).Start(); Will those threads stay...
4
by: Bails | last post by:
Hi Im an absolute beginner in programming and am using VB.Net Express. To start my larning I decided to do a "Real World" app instead of "hello world" and am creating a Poker Countdown clock. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.