date/time elapsed event

W

wanwan

Hi,

I'm looking for a better way to do a date/time elapsed event rather
than a timer elapsed event.

Currently, I wrote my program to use a timer elapsed event set to 1
second, and it checks the date/time in the event. Is there a better
way?


Thanks.
 
S

Stephany Young

It all depends on what your task needs to achieve.

If you explain that, then you are likely to get the appropriate advice.
 
W

wanwan

It all depends on what your task needs to achieve.

If you explain that, then you are likely to get the appropriate advice.

my program allows setting actions running as one time events or
recurrent events(weekly, monthly ...). I think my current approach
(i.e. using one second timer) is very inefficient because there is no
need to do the check so frequently.

I need to know if there is anything in vb.net I can use where the
event is triggered by date and time.

Thanks.
 
S

Stephany Young

Whatever you do, don't equate 'doing something frequently' with
'inefficient'.

Computers are designed to handle 'doing something frequently'. In fact
various parts of your computer are doing things 100's and even 1000's of
times every second.

Efficiency is more likely to be affected by what happens rather that how
often it happens.

The first thing you have to determine is the criticality of a task starting
on time.

By that I mean, is it critical that a task start precisely at a point in
time or is it acceptable that a task start within, say, 10 seconds of a
point in time.

If it is the latter than you can decrease the granularity of your timer to,
say, 10 seconds (10000 ms), instead of 1 second (1000 ms).
 
T

Tom Shelton

my program allows setting actions running as one time events or
recurrent events(weekly, monthly  ...). I think my current approach
(i.e. using one second timer) is very inefficient because there is no
need to do the check so frequently.

I need to know if there is anything in vb.net I can use where the
event is triggered by date and time.

Thanks.- Hide quoted text -

- Show quoted text -

Use the Windows Task Scheduler....

http://www.mvps.org/emorcillo/en/code/shell/tasksched.shtml

is just one possible interface...
 
W

wanwan

Whatever you do, don't equate 'doing something frequently' with
'inefficient'.

Computers are designed to handle 'doing something frequently'. In fact
various parts of your computer are doing things 100's and even 1000's of
times every second.

Efficiency is more likely to be affected by what happens rather that how
often it happens.

The first thing you have to determine is the criticality of a task starting
on time.

By that I mean, is it critical that a task start precisely at a point in
time or is it acceptable that a task start within, say, 10 seconds of a
point in time.

If it is the latter than you can decrease the granularity of your timer to,
say, 10 seconds (10000 ms), instead of 1 second (1000 ms).

Hi Steph,

what I mean is that my current approach is actually a form of polling.
It doesn't matter for one second timer or a ten second timer. For
example, a weekly event requires the program to run the event
repeatedly for a week before the computer actually does something
useful. Although modern computer can afford to waste these cycles,
it's still poor programming technique. Imagine what happens if I want
my program to handle 1000 weekly events with a precision of 1
millisecond?

what I am looking for is a way to wait on a date/time event based on
the concept of interrupt or blocking. So the program can better handle
large number of events.
I'm just hoping vb.net has something built in that I can use.


Eric
 
C

Cor Ligthert[MVP]

Wanwan,

It seems to me that your program (which is even not a Windows Service) has
to run everytime and the power should never goes down. (If it is a smaller
amount then you can calculate the ticks to that point and then set a timer
elapsing event to that point, but for a week this seems for me even to long
for a service). (Be aware that that timer event has as well to be processed,
however it is most probably faster than doing it yourself every time).

Have a look at the link that Tom is supporting around the scheduler.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top