Running Background tasks using IHostedService and BackgroundService (In ASP.NET Core 3.1)
#dotnetcore #aspnetcore #backgroundservices
Running background tasks in an ASP.NET Core application is often a necessity. Situations where we connect with cloud-managed services like streams and queues. They usually are implemented through continuously running methods. Because most of these managed cloud services are accessed via an HTTP connection, hence there are usually no callbacks.
In this video, I will walk through how to implement running background tasks using the following two methods:
1. Creating a class which implements IHostedService
2. And then creating a class which is derived from BackgroundService
In both cases, we will use the ConfigureServices extension method on the IHostBuilder instance for configuring the hosted service. Although the configuration of the background services can be done inside of the Startup class as well. And I am going to show both the variation in this video.
The hosted background services implementation is deeply integrated with the dependency injection of ASP.NET Core. That makes it very easy to implement the login into a testable component, whereas the hosted services are used only for invoking the components. I am going to demonstrate this as well in this video.
The source code for the video is available in GitHub here: https://github.com/choudhurynirjhar/backgroundtask-demo
Видео Running Background tasks using IHostedService and BackgroundService (In ASP.NET Core 3.1) канала DotNet Core Central
Running background tasks in an ASP.NET Core application is often a necessity. Situations where we connect with cloud-managed services like streams and queues. They usually are implemented through continuously running methods. Because most of these managed cloud services are accessed via an HTTP connection, hence there are usually no callbacks.
In this video, I will walk through how to implement running background tasks using the following two methods:
1. Creating a class which implements IHostedService
2. And then creating a class which is derived from BackgroundService
In both cases, we will use the ConfigureServices extension method on the IHostBuilder instance for configuring the hosted service. Although the configuration of the background services can be done inside of the Startup class as well. And I am going to show both the variation in this video.
The hosted background services implementation is deeply integrated with the dependency injection of ASP.NET Core. That makes it very easy to implement the login into a testable component, whereas the hosted services are used only for invoking the components. I am going to demonstrate this as well in this video.
The source code for the video is available in GitHub here: https://github.com/choudhurynirjhar/backgroundtask-demo
Видео Running Background tasks using IHostedService and BackgroundService (In ASP.NET Core 3.1) канала DotNet Core Central
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Worker Services in .NET Core 3.0 - The New Way to Create ServicesScheduling recurring jobs with Hangfire (In ASP.Net Core 3.1)Useful Configuration Management Tips And Tricks (In ASP.NET Core Application)C# Async / Await - Make your app more responsive and faster with asynchronous programming#123: Background Services in ASP.NET CoreWhat are Microservices in ASP.NET Core (My understanding and what I have learned so far)Background Tasks Without a Separate Service: Hangfire for ASP.NETASP.NET Core Video Upload Background ProcessingRabbitMQ in .NET Core (Part 1, Single producer and consumer with Queue)How to effectively use Redis Cache in .NET Core (Framework, Standard)How to build an API Gateway in ASP.NET Core using Ocelot (Build API Gateway in a few minutes)IDisposable Design Pattern (.Net Core)Worker Services in .NET Core (Background Services)Entity Framework Best Practices - Should EFCore Be Your Data Access of Choice?Creating a console-based microservice in .NET CoreC# Logging with Serilog and Seq - Structured Logging Made EasyGlobal Exception Handler (In ASP.NET Core)Adding a Service to an ASP.NET Core Website | ASP.NET Core 101 [4 of 13]Managing User SecretsConverting a Monolithic Application into Microservices in ASP.NET Core (The process I follow)