连续WebJob与定时器触发 [英] Continuous WebJob with timer trigger
问题描述
我已经写了下面的连续的网络工作职能:
I have written following functions in continuous web job :
public static void fun1([TimerTrigger("24:00:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timerInfo, TextWriter log)
{//Code}
public static void fun2([TimerTrigger("00:01:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timerInfo, TextWriter log)
{//code}
在这里,FUN1是没有得到再次调用(只有一次,在开始网络作业后)
和FUN2获取调用用1分钟触发每一个过程被完成之后。
where, fun1 is not getting called again (only once, after starting web job) and fun2 is getting called with 1 min trigger after every process gets completed.
谁能请解释一下为什么?
难道我做错了什么?
can anyone please explain why? Am I doing anything wrong?
推荐答案
您应该有一个看的 TimerTriggerAttribute
:
You should have a look at the documentation of the TimerTriggerAttribute
:
- 您指定的第一个参数是时间表前pression:
这可以是一个6场的crontab前pression或System.TimeSpan。
一个cron前pression可以重新presented这样的:
A Cron expression can be represented like that:
* * * * * command to be executed
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ │
│ │ │ │ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
│ │ │ └────────── month (1 - 12)
│ │ └─────────────── day of month (1 - 31)
│ └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)
在你的情况下,前pression是一个字符串重新presening时间跨度:
In you case, the expression is a string represening a TimeSpan :
-
24:00:00
:此作业运行每24小时,RunOnStartup
:这意味着当webjob启动或即使最后一次运行在过去24小时内发生重启作业的运行。
"24:00:00"
: this job is running every 24 hours,RunOnStartup
: this means the job will run when the webjob starts or restarts even if the last run occured in the last 24 hours.
00:01:00
:此作业正在运行的每一分钟, RunOnStartup
:这是指当webjob启动或重新启动作业将运行,即使在最后一分钟发生的最后一次运行。
"00:01:00"
: this job is running every minute, RunOnStartup
: this means the job will run when the webjob starts or restarts even if the last run occured in the last minute.
这篇关于连续WebJob与定时器触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!