I have a program for a client that needs to run one set of code every 30 minutes via a scheduled task.
at 1:30 am it needs to run a separate set of code.
Both sets of code will generate a file and place it in a directory.
How do I set it up to be able to run two sets of SQL code?
I could do it getting the current date time and comparing it but that seems bulky to me.
Is there a way a schedule task can run a program which would pass in something to my Main(string[] args)?
Is there a correct way to do it without creating two separate apps?
Make your program accept parameters, then schedule your console app (using Windows scheduler) with the different parameters... something like:
void Main(string[] args)
{
var firstArg = args.FirstOrDefault();
if (firstArg == "option1")
{
// do stuff
}
else if (firstArg == "option2")
{
// do other stuff
}
}
In scheduler do something like:
Write to flat file your param result from the first process, or database and get it from there with the second process.. Or just have your process always running and use stopwatch to perform events every 30 minutes instead of using the task scheduler, then you can keep it in memory. You have a lot of options.