|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How should I schedule a piece of code to run?I have the need for a function to be run at a set time each night. This function will be run on a machine that will have no-one logged on at the time this function will run. The alternatives that Im considering are 1) Create a windows service. Have a timer control in this service and set the interval to 24 hour and have the function being called on the Timer1_Tick event or 2) Create a app (which type?) that will be executed using a Scheduled Task What im not sure about is 1) Ive never created a servioce before so Im not sure if I can schedule this to run atspecific time of day or whether I shouyld use a timer control 2) Not sure what type of app to create so that I can run it from scheduled task without anyone logged on to machine. Could someone please advise. Some example code would be helpfull. Terry Holland You surely can set up a service to do this, but a timer is not your best
option. Any glitches in the system will cause it to reset and fire at the wrong time. You can poll time, of course, but watch that you do not put weight on your system. Scheduled jobs are a better option in many ways, although the windows scheduler can be a pain if you have lots of these jobs. The good news is you can switch to another scheduler in the future, if you go this route. -- Show quoteGregory A. Beamer ************************************************* Think Outside the Box! ************************************************* "Terry Holland" <terryholland@newsgroups.nospam> wrote in message news:eGNLHGNeGHA.3632@TK2MSFTNGP02.phx.gbl... > Im looking for some advice on the best direction to go in. > > I have the need for a function to be run at a set time each night. This > function will be run on a machine that will have no-one logged on at the > time > this function will run. The alternatives that Im considering are > > 1) Create a windows service. Have a timer control in this service and > set > the interval to 24 hour and have the function being called on the > Timer1_Tick > event > > or > > 2) Create a app (which type?) that will be executed using a Scheduled Task > > What im not sure about is > > 1) Ive never created a servioce before so Im not sure if I can schedule > this > to run atspecific time of day or whether I shouyld use a timer control > > 2) Not sure what type of app to create so that I can run it from scheduled > task without anyone logged on to machine. > > Could someone please advise. Some example code would be helpfull. > > Terry Holland > > Use the Windows Scheduler. I have a server with over a dozen jobs scheduled
this way and don't have any problems with any of them. Just remember, that any unattended application requires a "try...catch...end try" handler around the entire application nor can it expect any user input. Mike Ober. Show quote "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in message news:eeugJpNeGHA.1272@TK2MSFTNGP03.phx.gbl... > > You surely can set up a service to do this, but a timer is not your best > option. Any glitches in the system will cause it to reset and fire at the > wrong time. You can poll time, of course, but watch that you do not put > weight on your system. Scheduled jobs are a better option in many ways, > although the windows scheduler can be a pain if you have lots of these jobs. > The good news is you can switch to another scheduler in the future, if you > go this route. > > -- > Gregory A. Beamer > > ************************************************* > Think Outside the Box! > ************************************************* > "Terry Holland" <terryholland@newsgroups.nospam> wrote in message > news:eGNLHGNeGHA.3632@TK2MSFTNGP02.phx.gbl... > > Im looking for some advice on the best direction to go in. > > > > I have the need for a function to be run at a set time each night. This > > function will be run on a machine that will have no-one logged on at the > > time > > this function will run. The alternatives that Im considering are > > > > 1) Create a windows service. Have a timer control in this service and > > set > > the interval to 24 hour and have the function being called on the > > Timer1_Tick > > event > > > > or > > > > 2) Create a app (which type?) that will be executed using a Scheduled Task > > > > What im not sure about is > > > > 1) Ive never created a servioce before so Im not sure if I can schedule > > this > > to run atspecific time of day or whether I shouyld use a timer control > > > > 2) Not sure what type of app to create so that I can run it from scheduled > > task without anyone logged on to machine. > > > > Could someone please advise. Some example code would be helpfull. > > > > Terry Holland > > > > > > > Thanks
Schedular it is then :-) Show quote "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message news:uhPs8cOeGHA.380@TK2MSFTNGP04.phx.gbl... > > Use the Windows Scheduler. I have a server with over a dozen jobs scheduled > this way and don't have any problems with any of them. Just remember, that > any unattended application requires a "try...catch...end try" handler around > the entire application nor can it expect any user input. > > Mike Ober. > > "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in > message news:eeugJpNeGHA.1272@TK2MSFTNGP03.phx.gbl... > > > > You surely can set up a service to do this, but a timer is not your best > > option. Any glitches in the system will cause it to reset and fire at the > > wrong time. You can poll time, of course, but watch that you do not put > > weight on your system. Scheduled jobs are a better option in many ways, > > although the windows scheduler can be a pain if you have lots of these > jobs. > > The good news is you can switch to another scheduler in the future, if you > > go this route. > > > > -- > > Gregory A. Beamer > > > > ************************************************* > > Think Outside the Box! > > ************************************************* > > "Terry Holland" <terryholland@newsgroups.nospam> wrote in message > > news:eGNLHGNeGHA.3632@TK2MSFTNGP02.phx.gbl... > > > Im looking for some advice on the best direction to go in. > > > > > > I have the need for a function to be run at a set time each night. This > > > function will be run on a machine that will have no-one logged on at the > > > time > > > this function will run. The alternatives that Im considering are > > > > > > 1) Create a windows service. Have a timer control in this service and > > > set > > > the interval to 24 hour and have the function being called on the > > > Timer1_Tick > > > event > > > > > > or > > > > > > 2) Create a app (which type?) that will be executed using a Scheduled > Task > > > > > > What im not sure about is > > > > > > 1) Ive never created a servioce before so Im not sure if I can schedule > > > this > > > to run atspecific time of day or whether I shouyld use a timer control > > > > > > 2) Not sure what type of app to create so that I can run it from > scheduled > > > task without anyone logged on to machine. > > > > > > Could someone please advise. Some example code would be helpfull. > > > > > > Terry Holland > > > > > > > > > > > > > > > > Use the Windows Scheduler. I have a server with over a dozen jobs Don't forget about logging and notification on failures. It's great to have > scheduled this way and don't have any problems with any of them. Just > remember, that any unattended application requires a > "try...catch...end try" handler around the entire application nor can > it expect any user input. an application that gracefully closes, but you might be in trouble if you didn't realize that the scheduled job that processes the daily payroll failed for the last 2 weeks. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx |
|||||||||||||||||||||||