Тёмный

Running background tasks in ASP.Net Core 

Codewrinkles
Подписаться 28 тыс.
Просмотров 8 тыс.
50% 1

Опубликовано:

 

21 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 23   
@hanneskasel1853
@hanneskasel1853 Год назад
Hello Dan, i came across your channel through your Video about strongly-typed Results. Like your detailed work and the good explanations. Keep up.
@Codewrinkles
@Codewrinkles Год назад
Welcome aboard!
@jkaryskycoo
@jkaryskycoo 10 месяцев назад
Thanks for information.
@romeromedeiros3287
@romeromedeiros3287 2 года назад
Awesome, thank you very much!!
@Codewrinkles
@Codewrinkles 2 года назад
Glad it helped!
@Radhakrishna-pq3yj
@Radhakrishna-pq3yj 3 года назад
You are looking into swagger sample example output.. default values are just showing how the output will be shown in swagger... 🕺 The actual executed output is just above that.. . You got confused 😐
@Codewrinkles
@Codewrinkles 3 года назад
Yes, I noticed this too after uploading. Seems I was too tired when recording. Sorry for that.
@nikolaymarchin9296
@nikolaymarchin9296 2 года назад
Hi, I really enjoy your videos, keep up the good work! What approach would you take if you wanted to execute the background service at certain time every day?
@Codewrinkles
@Codewrinkles 2 года назад
There's also an option to set the Timer based on a CRON expression. This would require a 3rd party library named Cronos that helps you with Cron based timers directly in the DI container. Or you could use a 3rd party library for the whole thing, which might actually be easier. There are plenty of them out there but in my projects I usually use Hangfire.
@vaeluck01
@vaeluck01 Год назад
Thanks always for the way you make difficult subjects appear easy. It's same thing in all your videos. I also want to ask, assuming I want to run different background services? May be : 1. To send birthday messages daily 2. To send expired invoice reminders. I assume I can do that in one background service, whats your opinion?
@Codewrinkles
@Codewrinkles Год назад
I would stick to the single responsibility idea and create one background service for a group of actions that have the same reason for change. Sending birthday wishes and sending notification for expired invoices are two different business areas, so I would suggest having a dedicated service for each of them. Obviously, you can have an EmailSenderService that's responsible just for the technical part of sending emails. And you' inject this EmailService in both of the services mentioned earlier.
@vaeluck01
@vaeluck01 Год назад
@@Codewrinkles Thank you !
@baref0ot455
@baref0ot455 Год назад
Can you use this to automatically execute an API POST method that sends data to another api?
@Codewrinkles
@Codewrinkles Год назад
Sure, in a background service you can do whatever you want. You can use an HttpClient to make calls to an API if that's what it's required from the background service to do.
@vaeluck01
@vaeluck01 Год назад
I also hope you do a video on hangfire soon. Thanks.
@Codewrinkles
@Codewrinkles Год назад
Thinking about this for a longer time. Will probably do.
@vaeluck01
@vaeluck01 Год назад
@@Codewrinkles Thank you!
@habbabbutt3447
@habbabbutt3447 2 года назад
Sir i want my background service to be run everyday at 9 AM to 2PM on every 40 minutes of intervals how could i do that
@Dragonet17
@Dragonet17 Год назад
use hangfire
@mushroomhead5914
@mushroomhead5914 2 года назад
Bro, U didn't show us IWeatherForecastService. What a fail
@DOTNETMAN
@DOTNETMAN Год назад
public interface IWeatherForecastService { public List Forecast { get; set; } public WeatherForecast CurrentWeather { get; set; } }
@qqquery3840
@qqquery3840 3 года назад
Hi Sir. Can you make it to blazor too?
@Codewrinkles
@Codewrinkles 3 года назад
For Blazor Server, sure. It works exactly the same. It's the same hosting model as regular ASP apps. For Blazor WebAssembly we don't jave the concept of background services as those apps run in the browser. Like Angular, or React for instance. However, if you server your Blazor WebAssembly App from an Asp.Net Core host, then once again you can configure as many background services on the host as you need. But they are totally separated from Blazor itself. Bottom line: Wherever you have a .NET Core IWebHost running, you can add background services to it.
Далее
Middleware in ASP.NET Core - Part 1
21:04
Просмотров 15 тыс.
Wait for winner 🏆 😂 #shorts
00:42
Просмотров 3,3 млн
Using HttpClient in .NET Core to Connect to APIs in C#
45:03
Asynchronous APIs with .NET
1:02:17
Просмотров 38 тыс.
Don't Use AutoMapper in C#! Do THIS Instead!
16:17
Просмотров 68 тыс.
Background Tasks Are Finally Fixed in .NET 8
10:29
Просмотров 110 тыс.