Home All Groups Group Topic Archive Search About

How should I schedule a piece of code to run?

Author
16 May 2006 10:14 AM
Terry Holland
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

Author
16 May 2006 11:17 AM
Cowboy (Gregory A. Beamer)
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!
*************************************************
Show quote
"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
>
>
Author
16 May 2006 12:49 PM
Michael D. Ober
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
> >
> >
>
>
>
Author
16 May 2006 1:36 PM
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
> > >
> > >
> >
> >
> >
>
>
>
Author
16 May 2006 2:11 PM
Jim Wooley
> 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.

Don't forget about logging and notification on failures. It's great to have
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

AddThis Social Bookmark Button