I have a function that is in a continuous Azure WebJob and that function is required to be called once every 15 minutes.
Code in Program.cs
static void Main()
{
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
var host = new JobHost(config);
host.Call(typeof(Functions).GetMethod("StartJob"));
host.RunAndBlock();
}
Code in Function.cs
[NoAutomaticTrigger]
public static void StartJob()
{
checkAgain:
if (DateTime.Now.Minute % 15 == 0 && DateTime.Now.Second == 0)
{
Console.WriteLine("Execution Started on : " + DateTime.Now);
//Execute some tasks
goto checkAgain;
}
else
{
goto checkAgain;
}
}
Is my approach correct? As this is an infinite loop, will this code block incur any type of performance issue to the AppService under which this webjob is hosted.?