user386258
user386258

Reputation: 1953

c# I need to run a windowservice every sunday

I need to run a window service every sunday only once in c#. I cannot use window scheduler for that.How to use in c#.

Thanks

Upvotes: 2

Views: 483

Answers (3)

Jonathan
Jonathan

Reputation: 12025

You could check the date in the onstart event of your service, and do nothing if the date don't match your requisites. You could also load when do you want to execute your code from a file. Save aso the last time your code was executed to avoid do the work twice the same day.

Upvotes: 1

Rosmarine Popcorn
Rosmarine Popcorn

Reputation: 10967

You can use Quartz ,it's a great tool for scheduling Code ,and Here you can find an example how to run Windows Service from C#

Upvotes: 3

jeroenh
jeroenh

Reputation: 26782

Have a look at quartz.net, which is a task scheduling library that supports this scenario and many more.

It would still be much simpler to use the built-in task scheduler for such a simple scenario though...

Upvotes: 5

Related Questions