Hello everybody.
I want to call a specific function on my C# application at a specific time. At first i thought about using a Timer (System.Time.Timer), but that soon became impossible to use. Why?
Simple. The Timer Class requires a Interval in milliseconds, but considering that i might want the function to be executed, lets says in a week that would mean:
7 Days = 168 hours;
168 Hours = 10,080 minutes;
10,080 Minutes = 6,048,000 seconds;
6,048,000 Seconds = 6,048,000,000 milliseconds;
So the Interval would be 6,048,000,000;
Now lets remember that the Interval accepted data type is int, and as we know int range goes from -2,147,483,648 to 2,147,483,647.
That makes Timer useless in this case once we cannot set a Interval bigger that 2,147,483,647 milliseconds.
So i need a solution where i could specify when the function should be called. Something like this:
solution.ExecuteAt = "30-04-2010 15:10:00";
solution.Function = "functionName";
solution.Start();
So when the System Time would reach "30-04-2010 15:10:00" the function would be executed in the application.
How can this problem be solved?
Thanks just by taking the time to read my question. But if you could provide me with some help i would be most grateful.
Additional Info: What these functions will do?
Getting climate information and based on that info:
Starting / Shutting down other Applications (most of them Console Based);
Sending custom Commands to those Console Applications;
Power down, Rebooting, Sleep, Hibernate the computer;
And if possible schedule the BIOS to Power Up the Computer;
EDIT:
It would seem that the Interval accepted data type is double, however if you set a value bigger that an int to the Interval, and call Start() it throws a exception [0, Int32.MaxValue].
EDIT 2:
Jørn Schou-Rode suggested using Ncron to handle the scheduling tasks, and at first look this seems a good solution, but i would like to hear about some who as worked with it.