Solved

Alarm clock

Posted on 2000-05-12
9
191 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
Comment Utility
Yes, use the Task Scheduler.
0
 
LVL 9

Expert Comment

by:GivenRandy
Comment Utility
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
Comment Utility
For example,

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

0
 
LVL 2

Expert Comment

by:Crin
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 9

Expert Comment

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

Author Comment

by:Shish
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

9 Experts available now in Live!

Get 1:1 Help Now