Solved

Alarm clock

Posted on 2000-05-12
9
192 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now