我正在使用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");
}