Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Alarm clock

Posted on 2000-05-12
9
Medium Priority
?
199 Views
Last Modified: 2010-05-02
Is there any way to schedule tasks to launch without constanly running a timer to check the current date & time against the scheduled time?

This will need to run on a server, so I need to use as little processor and memory overhead as possible.
0
Comment
Question by:Shish
9 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2804991
Yes, use the Task Scheduler.
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805008
From fonnie:

  Yes, there is.  NT uses the AT scheduler service, (which is not started by default).  A GUI front end called WinAT is in the NT Resource Kit.
  Also, there are several third-party schedulers available.

  If the programs that need to run work ONLY on the local machine and do not need ANY network access, then AT is usable.  For running programs which use the network, I use WebWilly (I didn't name it) but there many others.




 
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805018
For example,

at 12:00 /every:Mo,Tu,We,Th,Fr,Sa,Su cmd /c batch.bat

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Crin
ID: 2805019
Hello,

When user set alarm time you can just calculate a number of milliseconds for Timer control and set Interval property to it. As soon as maximum of Interval property is 65,535 you can use API function Sleep that use Long for delay and make a loop with it with incremental counter or recalculator of estimated time before alarm.

Use

Public Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Sincerely yours,

Crin

0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805026
Since you said it is running "on a server", I assume the server is running WinNT (workstation or server).
0
 

Author Comment

by:Shish
ID: 2805030
It will get too messy if I try to use the Windows Task Scheduler.  I only need to run a few lines of code per alarm event, but I have dozens of alarm events.

Basically need to do just what the Task Scheduler does, but I want to run it from inside my program and keep it contained within the program.
0
 
LVL 2

Expert Comment

by:Crin
ID: 2805037
hehe :)

GivenRandy, your answer is absolete right, but it must be posted under Windows section, not VB... Same I could say to Shish if GivenRandy's comment is that you expected :))

Sincerely yours,

Crin
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 200 total points
ID: 2805819
A timer on a form does not use much in the way of processor cycles if the interval is set to 1000 or even 10000 (every ten seconds.)  If your scheduling code in the timer event is efficient, it should not impact the CPU in a significant way.  

In terms of memory, any VB program is going to come with the overhead of the VB runtimes, which is not insignificant, but probably won't cripple your server.

Crin's solution would work if you were only polling for one schedule event, but the sleep API will stop your program from checking for other events.
0
 
LVL 2

Expert Comment

by:Crin
ID: 2808789
Comment on PaulHews comment:
not for ONE scheduled event, but for sorted list of scheduled events :)))
And, of course, I forgot to describe that Sleep API freeze your programm...

Sincerely yours,
Crin

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

927 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