I have the main asp.net API application and am using HangFire for the first time.
In .Net Core, all my methods are asynchronous. Based on the SO Post, you should not use wait() when calling the asynchronous method in hangfire.
Also in accordance with the hangfire support issue in v1.6.0, asynchronous support has been added. I am using version 1.6.12, but still I do not see asynchronous support.
How do I call an asynchronous method from Enqueue . I am currently using wait()
public class MyController : Controller { private readonly Downloader _downlaoder; private readonly IBackgroundJobClient _backgroungJobClient; public MyController(Downloader downloader, IBackgroundJobClient backgroungJobClient) { _downlaoder = downloader; _backgroungJobClient = backgroungJobClient; } [HttpPost] public void Post([FromBody]IEnumerable<string> files) { _backgroungJobClient.Enqueue(() => _downloader.DownloadAsync(files).Wait()); } }
source share