Run a background task from a controller action in asp.net core 2

后端 未结 3 739
一向
一向 2020-12-23 09:16

I am developing a web application with a REST Api using C# with asp.net core 2.0

What I want to achieve is when the client send a request to an endpoint I will run a

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-23 10:16

    Microsoft has documented the same at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.1

    It accomplishes using BackgroundTaskQueue, which gets work assigned from Controller and the work is performed by QueueHostedService which derives from BackgroundService.

提交回复
热议问题