thread scheduling, how??

by Jeff on 12/14/2007 11:32:00 AM Hey

..NET 2.0

I'm working on a winservice created in .NET 2.0. Now I want to do some
modications to this winservice. I want this winservice at every start of a
new month to start a thread which pulls data from several webservices and
saves these data to table...

So I'm wondering how to go about implementing this so that this thread is
automatically started at a specific time. (lets say 03:30 am at day 1 on
each month).

maybe the winservice framework has some features for this?

any suggestions?


 

Re: thread scheduling, how??

by Jon Skeet [C# MVP] on 12/13/2007 6:25:00 PM On Dec 14, 9:31 am, "Jeff" <do...@spam.me> wrote:
> I'm working on a winservice created in .NET 2.0. Now I want to do some
> modications to this winservice. I want this winservice at every start of a
> new month to start a thread which pulls data from several webservices and
> saves these data to table...
>
> So I'm wondering how to go about implementing this so that this thread is
> automatically started at a specific time. (lets say 03:30 am at day 1 on
> each month).
>
> maybe the winservice framework has some features for this?

Is there any reason to put this into the windows service rather than
just using a Windows scheduled task?

Jon
 

Re: thread scheduling, how??

by Jeff on 12/14/2007 1:08:00 PM Thank you for the tip!

I think maybe the way to go is to create an app which in windows server 2003
can be configured as an scheduled task. And then make this app call the
winservice...

this app don't need any GUI., all it will do is retrieve information from
webservices and save it in a database

you agree it's best to create this app as a console app?


 

Re: thread scheduling, how??

by Jon Skeet [C# MVP] on 12/13/2007 7:26:00 PM On Dec 14, 11:08 am, "Jeff" <do...@spam.me> wrote:
> Thank you for the tip!
>
> I think maybe the way to go is to create an app which in windows server 2003
> can be configured as an scheduled task. And then make this app call the
> winservice...

Why should it call the windows service? When not just do the work
within the scheduled task?

> this app don't need any GUI., all it will do is retrieve information from
> webservices and save it in a database
>
> you agree it's best to create this app as a console app?

I'd create it as a Windows application which never shows any windows -
that way it won't try to create a new console window. On the other
hand, I realise that makes it slightly harder to debug :(

Jon
 

Re: thread scheduling, how??

by Willy Denoyette [MVP] on 12/14/2007 5:06:00 PM "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:c71f9b09-dd43-4991-968b-58e3b5086e1c@e25g2000prg.googlegroups.com...
> On Dec 14, 11:08 am, "Jeff" <do...@spam.me> wrote:
>> Thank you for the tip!
>>
>> I think maybe the way to go is to create an app which in windows server
>> 2003
>> can be configured as an scheduled task. And then make this app call the
>> winservice...
>
> Why should it call the windows service? When not just do the work
> within the scheduled task?
>
>> this app don't need any GUI., all it will do is retrieve information from
>> webservices and save it in a database
>>
>> you agree it's best to create this app as a console app?
>
> I'd create it as a Windows application which never shows any windows -
> that way it won't try to create a new console window. On the other
> hand, I realise that makes it slightly harder to debug :(
>
> Jon



Scheduled tasks (should ) run in a non visible desktop as they should be
able to run when no user is logged on, so there is no need for a Windows
Application, a (robust) Console app. is a perfect fit.

Willy.

 

Re: thread scheduling, how??

by Ben Voigt [C++ MVP] on 12/14/2007 8:02:00 AM
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:df9f3beb-9094-452c-936f-d77130f4c171@b1g2000pra.googlegroups.com...
> On Dec 14, 9:31 am, "Jeff" <do...@spam.me> wrote:
>> I'm working on a winservice created in .NET 2.0. Now I want to do some
>> modications to this winservice. I want this winservice at every start of
>> a
>> new month to start a thread which pulls data from several webservices and
>> saves these data to table...
>>
>> So I'm wondering how to go about implementing this so that this thread is
>> automatically started at a specific time. (lets say 03:30 am at day 1 on
>> each month).
>>
>> maybe the winservice framework has some features for this?
>
> Is there any reason to put this into the windows service rather than
> just using a Windows scheduled task?

The other option, if a service is needed, would be to leave a thread
sleeping with a waitable timer, not sure what the .NET wrapper for the
waitable timer API is.

But definitely better not to have a service started when not needed.

>
> Jon