Timer question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I need to do a task at 3pm everyday. How do I set up the timer so that the
timer procedure executes at 3pm everyday? Is there any other solution other
than using a timer?

Thanks.
 
I think you'd be better off using the windows task scheduler. Goto Control
Panel --> Scheduled Tasks and schedule your application to run at 3 pm
everyday. There are other useful options as well.

hope that helps..
Imran.
 
Can this be done programmatically?

I want to schedule a task programatically at a specified time of the day.

Regards
 
Hi SM,

Of course you can do this programmatically.
Dim mdate As Date

mdate = Now

MessageBox.Show(mdate.TimeOfDay.ToString)

This returns something like 09:43:16.1406250; from here it s/b easy to do
have your timer_tick method looking for a particular time and date and
reacting once it reaches 3:00 am.

HTH,

Bernie Yaeger
 
I think you'd be better off using the windows task scheduler. Goto Control
Panel --> Scheduled Tasks and schedule your application to run at 3 pm
everyday. There are other useful options as well.

hope that helps..

Yes - but he may have a program which is running all the time doing
something, and at 3pm has to do something else.

In this case, I would have an invisible form load with your
application and have something like (air code coming up....!)

Sub Form_Load
Do
do until format(now(),"HH:MM:SS") = "15:00:00"
doevents
loop
'it's now 3pm - and time to run the other process
Call Other Process
doevents
Loop
End Sub


I know it's not brilliant code - but you get the idea....
 
Wow...

That will eat up 50% CPU the entire time... [as per framework limitations]
 
Wow...

That will eat up 50% CPU the entire time... [as per framework limitations]

I know - but it's about the best solution "in program" without
resorting to the external scheduler...
 
Tym,
No using one of the 3 Timer objects in .NET would be the "best solution in
program"!

There are three distinct timer objects in .NET:
- System.Windows.Forms.Timer
- System.Threading.Timer
- System.Timers.Timer

There is also a Timer function in VB.NET, however it does not really allow
you to schedule an event to occur at a specific time.

Of course using one of the above Timer objects requires that your program
actually be running at the specified time. If the event has to occur I would
probably use Threading.Timer or Timers.Timer in a Windows Service, as the
service will always run, even without anyone logged in, Of course the
machine needs to be physically turned on!

The following article in MSDN Magazine explains the difference between the
three timer objects in .NET & when to use each.

http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx

The above article also discusses if & how each timer interacts with
threading.

Hope this helps
Jay

Tym said:
Wow...

That will eat up 50% CPU the entire time... [as per framework limitations]

I know - but it's about the best solution "in program" without
resorting to the external scheduler...
 

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

Back
Top