Reputation: 53
I have a console application which is based of multiple libraries and an entry point that trigger all these libraries. All of these libraries have their own background threads but one start up library that triggers all the other libraries. I will need to access the data in the cache that these libraries have processed and provide output from the controller.
I want to use these libraries (as continuously available services) in the .NET Core application as background service and host it in AWS. Is there a best way to go about it; I looked into DI but I lose/renew the instance every time the controller is called. I looked at Hangfire, but not sure it is for such activity. One way could be (I'm not sure) is to write WCF service and connect that with .NET core.
Upvotes: 3
Views: 8143
Reputation: 3177
You might want to look into using IHostedService in an ASP.NET Core application. It allows you to run background process within the process of the ASP.NET Core applications. Your web api controllers can access the background process as well. Here is a blog post that goes pretty in depth on IHostedService
https://www.stevejgordon.co.uk/asp-net-core-2-ihostedservice
Upvotes: 4