This is my first time I created a WebJob application type. I created a webjob project, and in the solution it comes with Program.cs and Function.cs .
I already deleted Function.cs , because in this project there is no queue from which I get data.
Now in Program.cs there already exists the Main method:
class Program {
As I understand it, RunAndBlock should constantly run webjob, but I want the task to be executed only once. I want to control execution from outside on a schedule. I would like to know how to make my code only once? As you can see below, I have a SupportService class that has RunOnePoolProvisioingCycle , I want to call this method only once. Is this the right approach?
static void Main() { SupportService _supportService = new SupportService(); _supportService.Initialize(); _supportService.SetPoolProvisioningConfigurations(); _supportService.RunOnePoolProvisioningCycle(); }
or this one?
static void Main() { var host = new JobHost(); SupportService _supportService = new SupportService(); _supportService.Initialize(); _supportService.SetPoolProvisioningConfigurations(); host.Call(typeof(SupportService).GetMethod("SetPoolProvisioningConfigurations")); }
or this one?
static void Main() { var host = new JobHost(); SupportService _supportService = new SupportService(); _supportService.Initialize(); _supportService.SetPoolProvisioningConfigurations(); host.CallAsync(typeof(SupportService).GetMethod("SetPoolProvisioningConfigurations")); }
or should I use:
host.Start()
or
host.StartAsync()?
source share