简体   繁体   中英

Asp.net Long-Running-Background-Task. Best Practice?

I have an Asp.net Core WebApp and a lot of Reports inside an MongoDB. Now I want to build a Service which gets a large Bunch of this Reports (with all dependecies and a lot of Screenshot), generates PDFs and put them in Zip and store them in the GridFS.

This would be a lot of work. But what is the best way to do it?

Something of these: https://learn.microsoft.com/en-us/as.net/core/fundamentals/host/hosted-services?view=as.netcore-6.0&tabs=visual-studio#consuming-a-scoped-service-in-a-background-task

Or should I only use a Service with a single async Task?

Microsoft says IHostedService . From Background tasks with hosted services in ASP.NET Core :

In ASP.NET Core, background tasks can be implemented as hosted services. A hosted service is a class with background task logic that implements the IHostedService interface. This article provides three hosted service examples:

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