我正在使用Azure WebJob從服務總線隊列中成功獲取消息。 但我想用這個相同的WebJob每5秒運行一些方法。具有隊列和System.Threading.Timer的Azure WebJob
我試過了以下方法,本地運行良好,但是當我發佈它時只運行一次。 天藍色日誌上沒有錯誤。
我在做什麼錯了?
感謝您的幫助。
static void Main()
{
try
{
var testTimer = new System.Threading.Timer(e => TestMethod(), null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(5));
SetupJobHost();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
private static void TestMethod()
{
Console.WriteLine("Test");
}