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?
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.
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?
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.
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 😐
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.
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.
Hello Dan, i came across your channel through your Video about strongly-typed Results. Like your detailed work and the good explanations. Keep up.
Welcome aboard!
Thanks for information.
Awesome, thank you very much!!
Glad it helped!
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?
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.
@@Codewrinkles Thank you !
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?
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.
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 😐
Yes, I noticed this too after uploading. Seems I was too tired when recording. Sorry for that.
I also hope you do a video on hangfire soon. Thanks.
Thinking about this for a longer time. Will probably do.
@@Codewrinkles Thank you!
Can you use this to automatically execute an API POST method that sends data to another api?
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.
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
use hangfire
Hi Sir. Can you make it to blazor too?
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.
Bro, U didn't show us IWeatherForecastService. What a fail
public interface IWeatherForecastService
{
public List Forecast { get; set; }
public WeatherForecast CurrentWeather { get; set; }
}