public class Program
{
public static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.NameResolver = new TimeResolver();
config.UseTimers();
JobHost host = new JobHost(config);
host.RunAndBlock();
}
private class TimeResolver : INameResolver
{
public string Resolve(string name)
{
string value = string.Empty;
switch (name)
{
case "TimerJob":
Console.WriteLine("Name Is TimerJob : " + name);
value = "00:00:10";
break;
case "TimerJobAlter":
Console.WriteLine("Name Is TimerJobAlter : " + name);
value = "00:00:20";
break;
}
return value;
}
}
//Runs once every 30 seconds
public static void TimerJob([TimerTrigger("%TimerJob%")] TimerInfo timer)
{
Console.WriteLine("Timer1 job fired!");
}
// Runs once every 60 seconds
public static void TimerJobAlter([TimerTrigger("%TimerJobAlter%")] TimerInfo timer)
{
Console.WriteLine("Timer2 job fired!");
}
}