这是我第一次使用WebJob类型的应用程序.我创建了一个webjob项目,并在解决方案中附带Program.cs和Function.cs.
我已经删除了,Function.cs因为在这个项目中没有队列,我将从中获取数据.
现在Program.cs已有Main方法如下:
class Program
{
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
}
Run Code Online (Sandbox Code Playgroud)
据我所知,这RunAndBlock是连续运行webjob,但我希望这项工作只运行一次.我想按计划从外部控制执行.我想知道如何让我的代码只运行一次?如下所示,我有一个SupportServiceClass RunOnePoolProvisioingCycle,我想只调用一次这个方法.这是正确的方法吗?
static void Main()
{
SupportService _supportService = new SupportService();
_supportService.Initialize();
_supportService.SetPoolProvisioningConfigurations();
_supportService.RunOnePoolProvisioningCycle();
}
Run Code Online (Sandbox Code Playgroud)
还是这个?
static void Main() …Run Code Online (Sandbox Code Playgroud)