Determine the 3rd Tuesday of each month, then perform an action c#

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I've created a service in c# that performs a certain action at a particular
day of the month

I want this service to kick off the action every third Tuesday of the month.
How would I set the service to run a desired action if the day is equal to
the third day of the month? Would that be done by programming it or using a
timer ? How would that be done.
 
Are you sure you don't want to use windows scheduler to do this? This way
your service isn't just running constantly checking if it's time to run yet.
The scheduler will just start your executable at the right time.
 
Marina Levit said:
Are you sure you don't want to use windows scheduler to do this? This way
your service isn't just running constantly checking if it's time to run
yet. The scheduler will just start your executable at the right time.

For a complex check like this, I think it would be best to use Task
Scheduler to start your program every day at a particular time, then let
your program check if it's the third Tuesday, or six days after a blue moon,
or during Lent, or whatever special check you need.
 
I think Task Scheduler already supports the concept of third Tuesday of
every month. I'm not sure what the advantage if of reinventing the wheel.

Sure, if the check goes beyond something that is already supported. But if
it's already there, why bother?
 
Marina Levit said:
I think Task Scheduler already supports the concept of third Tuesday of
every month. I'm not sure what the advantage if of reinventing the wheel.

Ok, seems that it does. I'm more familiar with the "at" command for
managing scheduled tasks, which seems to be less powerful schedule-wise (but
lets you run tasks under the SYSTEM account).
 
You're correct Task Schedular will let me do that, however on a domain
enviroment, don't I need a domain account for it to run under?
 
You can specify in the scheduler what account the executable should be run
under. You provide the credentials, and the scheduler runs that task as if
it were started by the user.
 
You can specify in the scheduler what account the executable should be run
under. You provide the credentials, and the scheduler runs that task as if
it were started by the user.
[snip]

Be careful (if you can) that the user you choose or create has a password that
does not expire. If you don't you'll have to go and change it at the end of
every expiration period. And that is a real pain ;o)
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
Back
Top