Creating Schedule Time

rinto_harianja

New member
Joined
Sep 23, 2005
Messages
1
Programming Experience
Beginner
Dear All Friend,

I want to make schedule task using Windows Service on VB.NET.
Every thursday at 9:00 PM. i want to make Alert(MEssage Box)

Thanks Friend,


Rinto Harianja
 
Here is the only thing that I can think of. Simply make a windows application with a timer and a function called checktime(). This checks the current time every time the timer ticks. And if the current time is 9:00 AM you can alert the user. Of course this application would have to be running which may be a bit cumbersome, but to accomplish that in about 5 minutes of programming time that is what I would suggest. All of this is contained within in the System.Datetime class I believe.
 
Hi Rinto,

Please find follwoing Sample code
VB.NET:
[SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] OnStart([/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2][] args)
{
StartWork();
}

[/SIZE][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][SIZE=2][COLOR=#008000] [/COLOR][/SIZE][SIZE=2][COLOR=#808080]<summary>
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][SIZE=2][COLOR=#008000] Stop this service.
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][SIZE=2][COLOR=#008000] [/COLOR][/SIZE][SIZE=2][COLOR=#808080]</summary>
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] OnStop()
{
[/SIZE][SIZE=2][COLOR=#008000]// TODO: Add code here to perform any tear-down necessary to stop your service.
[/COLOR][/SIZE][SIZE=2]}
System.Timers.Timer _tmrScheduler = [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2]; 
[/SIZE][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] StartWork()
{
_tmrScheduler = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] System.Timers.Timer(3000);
_tmrScheduler.Elapsed +=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] System.Timers.ElapsedEventHandler(_tmrScheduler_Elapsed);
_tmrScheduler.Enabled = [/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2];

}
[/SIZE][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] _tmrScheduler_Elapsed([/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] sender, System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("Result"); 
}
[/SIZE][CODE]
 
Remember the important thing is it must be running under Local System and in the Services Properties in SCM under the LogOn tab "Allow Service to inetract with Destop" should be checked.
 
- Jay
 
Back
Top