Below code demonstrates my Azure Worker role running that performs a task every day at 12 PM:
public override void Run()
{
try
{
while (true)
{
int time = Convert.ToInt32(DateTime.Now.TimeOfDay);
if (time == 12)
{
DoSomethingElse();
}
}
}
catch (Exception ex)
{
Log.Add(ex, true);
}
}
Here DoSomethingElse() is a method to send an email at every day 12 PM, and also fires once and only once per day.
How can I implement a scheduler that fire when the time is 12PM and execute DoSomethingElse()? And is this code the best method to use or should I use any 3rd party tool?