473,394 Members | 1,965 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,394 software developers and data experts.

firing an event at specific time or interval

Hi,

I want to be able to to have an event fired within my application at a
certain time on certain days (such as 2am Monday, Wednesday and Friday) as
well as other timers that fire an event based on a time interval (such as
every 3 minutes).

Out of the box there is the old timer1, which would cover the second
scenario, but is there a way to have the first timer done?

There maybe upto 50 different timers within the application.

Thanks

Jun 27 '08 #1
3 4990
The first thing you need to do is determine how little tolerance you can
live with for your 'forward' time-based events. For example, will it be
absolutely critical that they are fired at the exact time or will it be
alright if they are fired at a point up to 'some small time span' after the
nomintaed time (say, 1 minute)?

If it is the former then you are going to have jump through some hoops.

If it is the latter then it is relatively simple by implementing something
like:

Set the interval for your timer to the desired value,
(say 60000 - 1 minute)

Instantiate a queue object (preferably a generic one).
Enqueue a DateTime object for each required 'trigger point'.
Each 'trigger point' will represent it's next occurrence,
(e.g., 2 AM on Friday 23 May 2008).

When the Tick event for the timer fires, Peek the first
object in the queue.
If DateTime.Now >= 'the object' then DeQueue the object
and 'fire' the appropriate event.

In your 'event' EnQueue a new DateTime object for the next
occurrence of the required 'trigger point',
(e.g., 2 AM on Friday 30 May 2008).

When the application is termintaed, the content of the queue could be
persisted to a file and when the application is instantiated, the queue
could be repopulated from the file, so the whole mechanism can survive
restarts etc.
"Aussie Rules" <au****@nospam.comwrote in message
news:Ow*************@TK2MSFTNGP05.phx.gbl...
Hi,

I want to be able to to have an event fired within my application at a
certain time on certain days (such as 2am Monday, Wednesday and Friday) as
well as other timers that fire an event based on a time interval (such as
every 3 minutes).

Out of the box there is the old timer1, which would cover the second
scenario, but is there a way to have the first timer done?

There maybe upto 50 different timers within the application.

Thanks
Jun 27 '08 #2
Aussie Rules wrote:
Hi,

I want to be able to to have an event fired within my application at a
certain time on certain days (such as 2am Monday, Wednesday and
Friday) as well as other timers that fire an event based on a time
interval (such as every 3 minutes).

Out of the box there is the old timer1, which would cover the second
scenario, but is there a way to have the first timer done?

There maybe upto 50 different timers within the application.
There is no need for 50 different timers. Just make a list of datetimes that you
need something to happen, and what should happen.

Have a timer that fires every minute or so. When it fires, check the list. If
there is one that has elapsed, do that, and reset it to the next required time.
A single timer can manage a whole list of possible calls.
Jun 27 '08 #3
Funny how long it took Microsoft to decide that this was the way to do
it. They had multiple timers instead of one timer that serviced a time
sorted queue.

We all had to be careful not to use too many timers. There were 16 and
that was it! Try to use a 17th one and your program was history. And
you have no idea how many were in use. What a stupid idea!!

"The IRQ is in use." -- Really, WHAT IRQ???

"The file cannot be found." -- If you would just tell me the filename, I
COULD HELP!

"An unexpected error has occurred." -- ALL errors are unexpected. HELP
ME with some indication of what the error is! Oh, I see, you won't.
Thanks?

There are stronger answers to these STILL EXISTING error messages but
they are not fit to type here.

Mike

On Tue, 20 May 2008 22:26:03 -0700, in
microsoft.public.dotnet.languages.vb "Steve Gerrard"
<my********@comcast.netwrote:
>Aussie Rules wrote:
>Hi,

I want to be able to to have an event fired within my application at a
certain time on certain days (such as 2am Monday, Wednesday and
Friday) as well as other timers that fire an event based on a time
interval (such as every 3 minutes).

Out of the box there is the old timer1, which would cover the second
scenario, but is there a way to have the first timer done?

There maybe upto 50 different timers within the application.

There is no need for 50 different timers. Just make a list of datetimes that you
need something to happen, and what should happen.

Have a timer that fires every minute or so. When it fires, check the list. If
there is one that has elapsed, do that, and reset it to the next required time.
A single timer can manage a whole list of possible calls.
Jun 27 '08 #4

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

Similar topics

10
by: Andreas | last post by:
Hi! Is it possible to get a time event at a specific time, for instance eight a'clock? My program is running in the background and is minimized to the tray bar. If not, is there a smooth way...
4
by: Max | last post by:
I've noticed some procedures don't run in the global.asax when you'd expect them to. I've rebuilt and set break points, but Application_Start just isn't firing today. Is there some configuration...
4
by: Dan | last post by:
Hi, I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have elapsed without any user activity I want...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
14
by: TS | last post by:
I have this custom data list control and i override the onItemDatabound event. After upgrading to vs 2005, this event is not always getting called, though it does at other times. No changes were...
3
by: assgar | last post by:
Hi I am having problem with my loping. I don't know if I have chosen the correct approach. GOAL: I need to insert into a table event types for a specific date range. The calendar the event...
2
by: Johnny Jörgensen | last post by:
I've got a process I want to run in a thread separate from my main application thread, so I've used a backgroundworker component, and in frmMain.Load I invoke the code using...
1
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side....
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.