Set an “on demand” only job in HangFire

前端 未结 4 848
粉色の甜心
粉色の甜心 2021-02-13 17:18

In Hangfire, I have successfully set recurring jobs and am able to trigger manually if I want to, thanks to the Web UI and its \"trigger\" button.

RecurringJob.A         


        
4条回答
  •  走了就别回头了
    2021-02-13 17:57

    Yes, on demand jobs are entirely possible with hangfire. You can trigger fire-and-forget jobs using the following:

    BackgroundJob.Enqueue(
    () => Console.WriteLine("Simple!"));
    

    This however won't appear in the hangfire dashboard, but you can use the above snippet in your code (Perhaps after a button click?)

提交回复
热议问题