简体   繁体   中英

ASP.NET Core MVC long running operation

I have an ASP.NET Core application that executes a query based on user requested tokens, and is accessing external systems authenticated as the user. This request takes a long time to complete, and I want to make it asynchronous. To be able to do that I was looking into using a background service to offload the work, and to use SignalR to respond to data received events, however I can't find a good way to execute a long running task 'as a user' from an MVC controller action.

What is the preferred / best way to do this? Or am I missing something?

看一下托管服务 ,如果您想自己实现所有功能,这是aspnet执行长时间运行任务的核心方法,否则我也建议使用Hangfire

Yes, I will suggest using the Hangfire as it enables to schedule tasks with a Cron expression. Cron expression will allow you to set tasks with long intervals which can give sufficient time to complete long time tasks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM