Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I need to make an application that performs a task at a given time each day, based on the system time. For a simple example, lets say I want to delete all the files in a folder at 11:00 am everyday. The program would obviously be running on a computer thats always on. What is the best way to do this? Do I continuously compare the current time with the target time & when they're equal fire the event? This seems like a waste of cpu resources, but maybe thats the only way to do it. Can somebody post some code to get me started on this? Thanks...
Posted
Whilst you could program this, you could program something to achieve the effect and set it up using the windows task scheduler (thus not needing the timer code). Just a suggestion.
Anybody looking for a graduate programmer (Midlands, England)?
Posted

Rather than writing a service that is always running, why not write just a little program that does the job you need it to do and just that job (in this case deleting files) and use the Windows' Scheduled Tasks to allow it to run when you want it to run?

 

Heck, if all you're doing is deleting files rather then writing a program at all, write a batch file. That will do the trick and that's pretty darn easy.

  • Leaders
Posted
If task scheduler just can't handle your needs, there are better things to do than constantly compare time. The thread should probably spend most of it's time sleeping, hopping on once every minute or so, checking the time, and going back to sleep. This can be done with a Timer class or the Thread.Sleep() method.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...