title: C# - Alternative to System.Timers.Timer, to call a function at a specific time
body: <p><strong>I want to call a specific function on my C# application at a specific time.</strong> At first I thought about using a <code>Timer</code> <code>(System.Time.Timer)</code>, but that soon became impossible to use. Why?</p>
  
  <p>Simple. The Timer class requires a <code>Interval</code> in milliseconds, but considering that I might want the function to be executed, let's says in a week that would mean:</p>
  
  <ul>
  <li>7 days = 168 hours;</li>
  <li>168 hours = 10,080 minutes;</li>
  <li>10,080  minutes = 604,800 seconds;</li>
  <li>604,800 seconds = 604,800,000 milliseconds;</li>
  <li>So the interval would be 604,800,000;</li>
  </ul>
  
  <p>Now let's remember that the <code>Interval</code> accepted data type is <code>int</code>, and as we know <code>int</code> range goes from -2,147,483,648 to 2,147,483,647. </p>
  
  <p><strong>That makes <code>Timer</code> useless, not in this case, but in the case of more than about 25 days, once we cannot set a <code>Interval</code> bigger that 2,147,483,647 milliseconds.</strong></p>
  
  <hr>
  
  <p>So I need a solution where I could specify when the function should be called. <em>Something like this:</em></p>
  
  <pre><code>solution.ExecuteAt = "30-04-2010 15:10:00";
  solution.Function = "functionName";
  solution.Start();
  </code></pre>
  
  <p>So when the System Time would reach "30-04-2010 15:10:00" the function would be executed in the application.</p>
  
  <p><strong>How can this problem be solved?</strong></p>
  
  <hr>
  
  <p><strong>Additional information: What will these functions do?</strong></p>
  
  <ul>
  <li>Getting climate information and based on that information:</li>
  <li>Starting / Shutting down other applications (most of them console based);</li>
  <li>Sending custom commands to those console applications;</li>
  <li>Power down, rebooting, sleep, hibernate the computer;</li>
  <li><em>And if possible schedule the BIOS to power up the computer;</em></li>
  </ul>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It would seem that the <code>Interval</code> accepted data type is <code>double</code>, however if you set a value bigger that an <code>int</code> to the <code>Interval</code>, and call <code>Start()</code> it throws a exception <code>[0, Int32.MaxValue]</code>.</p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>Jørn Schou-Rode suggested using <a href="http://code.google.com/p/ncron/" rel="noreferrer">Ncron</a> to handle the scheduling tasks, and at first look this seems a good solution, but I would like to hear about some who has worked with it.</p>