3
Guys I have an api where your processing takes around 6 hours of execution, so I added a Task.Factory.Startnew with the main processing. So when someone calls, she responds to Statuscode 200 and continues processing "heavy" with the Task:
public override async Task<HttpResponseMessage> Processar(TarefaViewModel tarefa){
var task = Task.Factory.StartNew(() =>
{
var result = ProcessamentoDe6HorasNoBanco();
// Chama HttpClient e responde para outra api externa:
RequestPostStatusGerenciador(result, tarefa.Id, Action.Processar);
}, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
return await ResponderAccepted("OK");
}
However, back and forth the Task is not called I have to recycle the IIS to get back to normal. I suspect it is something related to the IIS Cache. Can anyone shed any light on that? In the properties of Task.Factory.Startnew, such as Taskcreationoptions.Longrunning would make a difference?
How you use Hangfire with Usememorystorage to run a Schedule every 30 seconds ?
– FernandoPaiva
I don’t use Hangfire with data in memory, the smallest unit that hangfire implements from interval is minute. I gave a search and all the places I found no one could implement task to execute in the unit of seconds
– Pablo Tondolo de Vargas
Nor with
TimeSpan.FromMinutes(1)
works. I no longer know what to do. Soh runs 1x when starting, does not trigger the Schedule in the given time– FernandoPaiva
take a look at my project https://github.com/pablotdv/CodingCraftEX06HangFire, I use hangfire
– Pablo Tondolo de Vargas