BACKGROUND TASKS in ASP NET Core | Getting Started With ASP.NET Core Series

  Рет қаралды 37,681

Rahul Nath

Rahul Nath

3 жыл бұрын

Hello, Background tasks are those that run in the background without interfering with the primary process. In ASP NET Core background tasks are implemented as Hosted Services. This allows us to perform tasks outside of the main web thread, determine changes to data in a database, and also long-running tasks to process messages from the queue, etc.
In this video let's learn how to create and run a task in the background in ASP.NET Core applications. We will learn how to use the BackgroundService class, how to register it to work with the ASP NET Application. We will also see how the IHostedService interface works along with the BackgroundService and also the different Dependency Injection models it supports.
Additional Watching
📹Dependency Injection - • DEPENDENCY INJECTION i...
📹Logging - • LOGGING in ASP.NET Cor...
📹ASP NET Core Series - • ASP.NET Core
Come say hi! ✋
🌍 Blog - rahulpnath.com/
✉ Subscribe to my Newsletter - www.rahulpnath.com/subscribe
🐦Twitter - / rahulpnath
📸Instagram - / rahulpnath
🎥 Recording Setup and Workflow - www.rahulpnath.com/blog/youtu...
Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

Пікірлер: 189
@BM-jy6cb
@BM-jy6cb Жыл бұрын
I love the way you just get down to it in your videos. No waffle, but all the detail needed as a jumping off point. Excellent. Thank you.
@RahulNath
@RahulNath Жыл бұрын
Awesome! Thank you! Hope you are enjoying the full series bit.ly/asp-net-core-series
@xbenchers1116
@xbenchers1116 3 жыл бұрын
One of my favorite on KZfaq. Thank you Sir for the great explanation.
@RahulNath
@RahulNath 3 жыл бұрын
So nice of you. And you can call me Rahul 😀
@BM-jy6cb
@BM-jy6cb Жыл бұрын
Now 23k subscribers, but this channel deserves so much more!
@sachinichathurika9507
@sachinichathurika9507 2 жыл бұрын
Simple and very clear tutorial. Thank you for the great information.
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Sachini. Do check out the full series here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP I am sure you will like them too! Do let me know in case you get to watch them 😀
@shashikantpawar7069
@shashikantpawar7069 3 жыл бұрын
Please smile a bit ...u crossed 5k😃😃. Congratulations
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Shashikant! Once the camera is on I always forget to smile 😀 (But otherwise I do). With time I hope I will get better at this.
@girmamoges941
@girmamoges941 Жыл бұрын
Excellent presentation by providing first level easy to understand examples, you are my vote !!!
@RahulNath
@RahulNath Жыл бұрын
Wow, thank you! Glad you are finding it useful and hope you are liking the series bit.ly/asp-net-core-series
@sufyannisar
@sufyannisar 2 жыл бұрын
Simple and to the Point! Great Tutorial!
@RahulNath
@RahulNath 2 жыл бұрын
Glad you liked it Sufyan! do check out the full playlist here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@keerthang5557
@keerthang5557 3 жыл бұрын
Excellent Tutorial Rahul, eagerly waiting for part 2!
@RahulNath
@RahulNath 3 жыл бұрын
Glad you like it Keerthan and thank you for this video suggestion!
@thegaribovv
@thegaribovv Жыл бұрын
Thanks man, I love your explanation because your are not skipping the boundary cases
@RahulNath
@RahulNath Жыл бұрын
Glad it was helpful! Hope you are enjoying the full series bit.ly/asp-net-core-series
@anuragnigam55
@anuragnigam55 2 жыл бұрын
Great content 👍 The simplicity with which ur going in deep about the topic is amazing
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Anurag! Feel free to let know if you have topic suggestions.
@TellaTrix
@TellaTrix 2 жыл бұрын
Superb ! I been facing this problem lot a time. i was not able to inject scoped and transient dependency into singleton. It's too late to know but finally i got my answer. Keep tuned us.
@RahulNath
@RahulNath 2 жыл бұрын
Glad to hear that
@shovonku
@shovonku Жыл бұрын
Your presentation style is very simple and to the point. Keep up the good work, Rahul.
@RahulNath
@RahulNath Жыл бұрын
Glad you like it. Hope you are enjoying the series bit.ly/asp-net-core-series
@northshorepx
@northshorepx Жыл бұрын
Excellent Video!!! Thank you
@RahulNath
@RahulNath Жыл бұрын
You are welcome! Hope you are enjoying the series bit.ly/asp-net-core-series
@hadirezaee7292
@hadirezaee7292 3 жыл бұрын
like always, short, simple and usefull
@RahulNath
@RahulNath 3 жыл бұрын
Thank uou Hadi !
@shanmuka16
@shanmuka16 Жыл бұрын
Guys let's encourage this channel, tremendous content ❤❤
@RahulNath
@RahulNath Жыл бұрын
Thank you for the love Shanmukh! Hope you are enjoying the series bit.ly/asp-net-core-series
@nirajchandrajoshi
@nirajchandrajoshi Жыл бұрын
Great presentation and complete information in one tutorial... great job.
@RahulNath
@RahulNath Жыл бұрын
Glad you loved it Niraj! Do check out the full series here bit.ly/asp-net-core-series
@dsfgato
@dsfgato 2 жыл бұрын
Such a great content, Rahul!! You're helping me so much with these tutorials. Greetings from Sao Paulo (BR).. cheers
@RahulNath
@RahulNath 2 жыл бұрын
Happy to hear that Douglas! Hope you are enjoying the series bit.ly/asp-net-core-series
@rushanthannelson513
@rushanthannelson513 Жыл бұрын
Thanks, Rahul; your content is always meaningful and applicable to real solutions. Keep up the great work!! Can you make one with scheduled tasks in background services, please?
@atulsingh29
@atulsingh29 2 жыл бұрын
I'm new to .net core and this problem held me for two days, can't thank you enough 🙏
@RahulNath
@RahulNath 2 жыл бұрын
Great to hear Atul! The full ASP Series is here, I am sure you will like them bit.ly/asp-net-core-series
@atulsingh29
@atulsingh29 2 жыл бұрын
@@RahulNath I'm already on it. ⭐⭐⭐⭐⭐
@RahulNath
@RahulNath 2 жыл бұрын
@@atulsingh29 Do drop in if any topic suggestions and feedback 😀👍
@jackReme
@jackReme 2 жыл бұрын
Thanks a lot! Great content!
@RahulNath
@RahulNath 2 жыл бұрын
Glad you liked it Jack! The full ASP series is here bit.ly/asp-net-core-series
@efeamioku3220
@efeamioku3220 2 жыл бұрын
I believe this tutorial will help me implement the MS Azure Service Bus Queue as a background service and via IServiceProvider Dependency Injection use repository pattern scoped service to save queue messages to my entityframework SQL Server DB which I will be able to read via my API controller and display to a frontend via API calls using react js. I hope this works...
@efeamioku3220
@efeamioku3220 2 жыл бұрын
Yes, It worked. Thanks...
@RahulNath
@RahulNath 2 жыл бұрын
Glad to hear that! Thank you Efe 😀
@fahadnoor2579
@fahadnoor2579 3 жыл бұрын
Excellent
@RahulNath
@RahulNath 3 жыл бұрын
Thank you so much Fahad😀 Make sure to check out the other videos in this series kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@Latif127
@Latif127 2 жыл бұрын
Very helpful tutorial. Thank you.
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful Abdul!
@pramod.kulkarni9607
@pramod.kulkarni9607 Жыл бұрын
Amazing Tutorial Rahul.
@RahulNath
@RahulNath Жыл бұрын
Glad you found it useful. The full series is here bit.ly/asp-net-core-series
@khaiquocpham7747
@khaiquocpham7747 Жыл бұрын
Thank you. The content you make is very easy to understand. Hope you will make more videos
@RahulNath
@RahulNath Жыл бұрын
Glad you like it. The full ASP series is here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@aravindmaestro1492
@aravindmaestro1492 2 жыл бұрын
Really helpful.... thanks for uploading some great .net contents..easily understandable...waiting for more such content . Thanks Rahul 😊
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Aravind. Do check out the full series here if you haven't already kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Feel free to let know if you have specific topic suggestions.
@ivanpesenti1138
@ivanpesenti1138 3 жыл бұрын
As usual amazing video Rahul. Thanks for your work and time 😄
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Ivan! These comments make it worth my time, thank you for watching.
@jamesthompson2122
@jamesthompson2122 3 жыл бұрын
Always helpful and informative! Get some rest though, I saw the time on your build as 5:02 am! :)
@RahulNath
@RahulNath 3 жыл бұрын
Glad you like it and thank you for the lovely caring comment. I record all my videos during that time (4-5) 😀 (That's when house is least noisy). Wrote about it here if you are interested. twitter.com/rahulpnath/status/1393813849933897737?s=20
@praveenthakur6908
@praveenthakur6908 Жыл бұрын
Great explanation Rahul👍👍👍
@RahulNath
@RahulNath Жыл бұрын
Glad you like it Praveen. Hope you are enjoying the series bit.ly/asp-net-core-series
@manjinderbajwa1468
@manjinderbajwa1468 2 жыл бұрын
Excellent keep it up
@RahulNath
@RahulNath 2 жыл бұрын
Thanks a lot! Hope you are liking the series bit.ly/asp-net-core-series
@ksdvishnukumar
@ksdvishnukumar 3 жыл бұрын
As usual explained very well Rahul...Thanks a ton bro...👍
@RahulNath
@RahulNath 3 жыл бұрын
Thank you 😀 So happy these help and for letting me know.
@harmeetchandok7824
@harmeetchandok7824 3 жыл бұрын
Thanks for this video
@RahulNath
@RahulNath 3 жыл бұрын
Most welcome Harmeet. Do check out the other videos in this series kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@my4127
@my4127 2 жыл бұрын
You are so awesome! Thank you!
@RahulNath
@RahulNath 2 жыл бұрын
You are so welcome! Hope you are enjoying the full series here bit.ly/asp-net-core-series
@christiantobler7628
@christiantobler7628 2 жыл бұрын
Great video and very clear explanation !
@RahulNath
@RahulNath 2 жыл бұрын
Glad you enjoyed it Christian! Do check out the full ASP Series here bit.ly/asp-net-core-series
@lamhongbac
@lamhongbac 5 ай бұрын
Cảm ơn bạn!
@parwejp
@parwejp 3 жыл бұрын
Nice. Thank you. Unit test cases on background services as well next time. Will share nuget packages on which videos could be created. I forgot about that.
@RahulNath
@RahulNath 3 жыл бұрын
Thank you and good idea - will try and add testing too in it.
@haroonahmad731
@haroonahmad731 2 жыл бұрын
Very helpful
@RahulNath
@RahulNath 2 жыл бұрын
Glad it helped - Do check out the full series here bit.ly/asp-net-core-series Hope you like them
@expertreviews1112
@expertreviews1112 2 жыл бұрын
That is an excellent video… really really loved it…thnxx
@RahulNath
@RahulNath 2 жыл бұрын
Glad you liked it! Hope you have checked the full series bit.ly/asp-net-core-series
@hamadsherazi6896
@hamadsherazi6896 Жыл бұрын
Rahul its a great video. I saw each sec enjoying the content
@RahulNath
@RahulNath Жыл бұрын
Glad to hear that Hamad. Sure that you will enjoy the full series then bit.ly/asp-net-core-series
@deivamanidhandabani9505
@deivamanidhandabani9505 2 жыл бұрын
Great Lesson Rahul keep doing the same.
@RahulNath
@RahulNath 2 жыл бұрын
Glad you like it - The full series for ASP is here bit.ly/asp-net-core-series
@deivamanidhandabani9505
@deivamanidhandabani9505 2 жыл бұрын
@@RahulNath Could you please explain concurrent collections in C# or send me the link if you have already done the videos. Thanks
@navaneethakrishnan1532
@navaneethakrishnan1532 Жыл бұрын
nice Explanation Rahul
@RahulNath
@RahulNath Жыл бұрын
Happy you liked it. Do check out the full series here bit.ly/asp-net-core-series
@tobbyechonga2461
@tobbyechonga2461 2 жыл бұрын
Thank you very helpful.
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful Tobby! Do check out the full series here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@abdullah.nayem.enosisbd
@abdullah.nayem.enosisbd Жыл бұрын
Thanks
@hozaifamohammed4894
@hozaifamohammed4894 2 жыл бұрын
Thank you bro
@RahulNath
@RahulNath 2 жыл бұрын
Glad it helped. Do check out the full series here bit.ly/asp-net-core-series
@Ibrahimnada1995
@Ibrahimnada1995 2 жыл бұрын
good job man
@RahulNath
@RahulNath 2 жыл бұрын
Glad it helped Ibrahim. Do check out the full series here bit.ly/asp-net-core-series
@hector9079
@hector9079 3 жыл бұрын
Muy bueno
@RahulNath
@RahulNath 3 жыл бұрын
Gracias!
2 жыл бұрын
Good job with the tutorial, could you create some on how to use the QUARTZ library in net core, since the ones that are currently there are very confusing and I think you would make them much easier to understand.
@RahulNath
@RahulNath 2 жыл бұрын
Glad you like the video and Great suggestion! I will add this to my list. I have a blog post from a while back here using Quartz in case it helps www.rahulpnath.com/blog/windows-service-using-topshelf-quartz-and-autofac/
@sonalirane4667
@sonalirane4667 2 жыл бұрын
Hi Rahul, Amazing video, Can you do a video on reading from database when hosted service starts
@RahulNath
@RahulNath 2 жыл бұрын
Sure happy to - Can you elaborate on your use case, to get some more idea.
@pratikkapadia560
@pratikkapadia560 2 жыл бұрын
Good one Rahul, if possible please make video on reading from database when hosted service starts, e.g persistent queue. But really like your videos
@RahulNath
@RahulNath 2 жыл бұрын
Thats a good suggestion Pratik. I will add that to my list. Glad you like the videos
@shirazeditar5006
@shirazeditar5006 Жыл бұрын
👍
@RahulNath
@RahulNath Жыл бұрын
😀
@ElyinAnuarSarriaMontenegro
@ElyinAnuarSarriaMontenegro 10 ай бұрын
Hola buenas Un vídeo de worker services sería de mucha ayuda Saludos
@abhishekks6782
@abhishekks6782 2 жыл бұрын
waiting for In Part 2, please give example with some real time examples.
@RahulNath
@RahulNath 2 жыл бұрын
Yes, it's on the list! Thank you for the prompt 😀
@MrSachintelalwar
@MrSachintelalwar 2 жыл бұрын
Another great video! I knew about Background service but did not know the limitation you demoed. Thank you for pointing that. Also, You mentioned that there is a new video coming for exception handling for Background services, can you please add a link for that?.
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful Sachin! Unfortunately I did not get to that video. Are you facing any particular issues? I might look to work on that video soon.
@MrSachintelalwar
@MrSachintelalwar 2 жыл бұрын
@@RahulNath Not facing any issue as such but curious to see how you will handle it.
@RahulNath
@RahulNath 2 жыл бұрын
@@MrSachintelalwar Have it in my list, yet to get to it 😀
@bloopers2967
@bloopers2967 3 жыл бұрын
Very well explained, can you please make video on logging in asp.net core and generic, non generic collections in asp.net core
@RahulNath
@RahulNath 3 жыл бұрын
Thank you 😀 For logging kzfaq.info/get/bejne/mt5yn6Wd2auogqc.html Does that help? What specifically are you looking for with collections?
@bloopers2967
@bloopers2967 3 жыл бұрын
@@RahulNath like how to use non- generic collections in a real world scenario
@RahulNath
@RahulNath 3 жыл бұрын
@@bloopers2967 Mmm that is interesting. I usually don't use that much. What scenario are you using non-generic currently for?
@bloopers2967
@bloopers2967 3 жыл бұрын
@@RahulNath 😂😂for solving competitive coding questions
@RahulNath
@RahulNath 3 жыл бұрын
@@bloopers2967 Haha ok, one more reason to hate such questions 😂🤣
@BlalKhalidTech
@BlalKhalidTech 4 ай бұрын
Hello,What if we want run background service even the application is close?
@RahulNath
@RahulNath 4 ай бұрын
the background job should be running as long as your web app is up and running. Otherwise I would be looking at Azure Function instead of using a Background Task. Does that help?
@deporesmartino1472
@deporesmartino1472 2 жыл бұрын
hi Rahul, If I deploy service as window service, and some one stop service on service window when it running, how we get the information of stop time
@ershadnozari
@ershadnozari 3 жыл бұрын
Hi Rahul, thanks for a another brilliant video. I’m looking for a azure devops ci/cd example for the new Logic Apps Standard. Do you know of a good resource for this? Not looking for entire IaC, rather just continuously build and deploy on commit
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Ershad and happy you like it. Did you find anything interesting on this channel? kzfaq.info I haven't worked with Logic Apps much.
@ershadnozari
@ershadnozari 3 жыл бұрын
@@RahulNath Hi Rahul, the logic app standard sku just recently went GA with MS Build. Previous devops story for logic app was different. The new logic app standard is running on the azure functions runtime, so it is very similar to app services in terms of ci/cd. But I can’t find a good example as it’s so new.
@subikshapadmanabhan5842
@subikshapadmanabhan5842 Жыл бұрын
Hi! I want to save excel files into the local server once every year using scheduler so may i know how to call the excel generating api from my existing controller in my scheduler class
@JitheshChandrasekharan
@JitheshChandrasekharan 2 жыл бұрын
Its a hosted service in WebApp, so if I host that web app in Azure? How will the background task behave? So we duplicate background tasks when we scale web app? So background task should manage some locks to avoid duplication? Any thoughts?
@RahulNath
@RahulNath 2 жыл бұрын
Sorry for delay in getting back. Yes as you scale there will be multiple instances. What problem are you trying to solve using background tasks? Using Azure Functions might be another way if you want to control the number of instances and always want only one instance.
@andrewreiser3584
@andrewreiser3584 2 жыл бұрын
Serious question. Someone told me that these tasks are utterly unreliable in Azure. Do you have any experience using them in App Services in Azure? Cheers
@RahulNath
@RahulNath 2 жыл бұрын
Yes I've used this in production in Azure App Service and have had no issues. Depends a lot on how they have used/what error handling mechanisms they have in place. Another option for you would be to make it a web job. What is your scenario?
@iniudoh5941
@iniudoh5941 2 жыл бұрын
Hi Rahul, great content! I have a bit of an usage when I fake the scope. It's affecting the IHttpContextAccessor, making it return null. can you help?
@RahulNath
@RahulNath 2 жыл бұрын
Thank you - Do you have a example project that you can send me? hello@rahulpnath.com
@diegomelgar2696
@diegomelgar2696 10 ай бұрын
Hi Rahul, thanks for your video!! In scenarios where the application is abruptly closed, does it exists a workaround how to handle those abruptly closings?
@RahulNath
@RahulNath 10 ай бұрын
It's best to use external queues for critical processing and avoid the background tasks for this as you might loose information. What is your scenario you are using this for?
@diegomelgar2696
@diegomelgar2696 10 ай бұрын
@@RahulNath what type of external queues do you refer? Is a hypothetical scenario of thousand of data to process daily, maybe for example financial institution usually process thousands of records to process loans. I was thinking of batch data split in multiple jobs/tasks ?
@RahulNath
@RahulNath 10 ай бұрын
@@diegomelgar2696Azure Service Bus Queue, AWS SNS, SQS , Rabbit MQ etc depending on where and how your application is hosted/managed. I have some introduction to this in my Messaging series here kzfaq.info/sun/PL59L9XrzUa-ku74pfBcy4f3tigwfzGUrG For critical processing I wouldn't depend on Background Tasks.
@diegomelgar2696
@diegomelgar2696 10 ай бұрын
@@RahulNath thanks, will check on that!
@habbabbutt3447
@habbabbutt3447 2 жыл бұрын
I want my background service to be run every day at 9AM and run after every 40 minutes till 2PM can you please guide
@RahulNath
@RahulNath 2 жыл бұрын
Suggest looking at WebJobs and using CRON trigger. You could also do this in Background Tasks. Check out libraries like Quartz.net. Hope it helps
@santanderhernandezcontador2875
@santanderhernandezcontador2875 8 ай бұрын
How do you deploy in IIS? do you have an example?
@RahulNath
@RahulNath 7 ай бұрын
I don't have an example for IIS - there are a few on my channel to deploy to Azure Web App bit.ly/azure-devops-series
@rohandeshpande5850
@rohandeshpande5850 3 жыл бұрын
could you please make videos on Razor pages and Core Blazor
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Rohan for the suggestion. I have added this to my list. But that will not be coming out immediately. Mostly because I have not explored much of Blazor 😀
@vadivelk7666
@vadivelk7666 Жыл бұрын
I want to run my background task for every 30 seconds throughout the year. For this scenario, can I use this approach? Please advice.
@RahulNath
@RahulNath Жыл бұрын
Sure you can - but if the app is down it won't run, so keep that in mind. Might look at Azure Function on a Timer trigger as well depending on the task and how important it is etc.
@josephrozario6237
@josephrozario6237 2 жыл бұрын
Nice Tutorial! I want to build a api that start and stop the background task .how can I do that ?if so,than is it the wise way to start and stop the background task?
@RahulNath
@RahulNath 2 жыл бұрын
You could - Can you provide more details on the use case ?
@mdaslamknl
@mdaslamknl Жыл бұрын
Good Why don't you give real life scenerio Thanks
@roslanbainal5914
@roslanbainal5914 2 жыл бұрын
this method can be used for sending email automatically for specific user which is inactive user more than 6 month?
@RahulNath
@RahulNath 2 жыл бұрын
Yes you could, but if you are on Azure I might use a Web Job or an Azure Function for that. But that said, you could very well do that in BackgroundTask as well
@roslanbainal5914
@roslanbainal5914 2 жыл бұрын
@@RahulNath thank you sir for your explanation 👍
@RahulNath
@RahulNath 2 жыл бұрын
@@roslanbainal5914 No probs Roslan. And you can call me Rahul 😀
@shashankpandey1019
@shashankpandey1019 Жыл бұрын
Very nice tutorial ☺️ just i have a question that can we run hosted service as per own events. e.g - when task A is completed then we need to fire background service to execute Task B ?
@RahulNath
@RahulNath Жыл бұрын
Yes you can use Channels library for this learn.microsoft.com/en-us/dotnet/core/extensions/channels But depends what kind of tasks and be aware it will be in memory. If you provide more context on the problem I could give some suggestions.
@shashankpandey1019
@shashankpandey1019 Жыл бұрын
Thank You for reply!! I have to read an excel having 20k rows and after reading this, we need to execute some business logic for each row. 1. upload an Excel 2. Reading Rows and storing in DB. 3. click on the start process button. 4. Now we will read all the data from the table and perform some tasks (Business logic) in the background for each row (Total around 20k rows). 5. Tech Using .Net Core 3.1
@RahulNath
@RahulNath Жыл бұрын
@@shashankpandey1019 I would use messaging for this - so publish a message for each row and process it independently. You can also use background tasks. Once you save the excel records to database signal the background worker using Channels or you can use polling from background job for new jobs/rows in the database. A Message Queue is ideal for these scenarios instead.
@shashankpandey1019
@shashankpandey1019 Жыл бұрын
Thanks a Lot @RahulNath 😊! It's working for me. I have looked at all your videos. it's an amazing learning. Happy leaning!
@oggyoggy3033
@oggyoggy3033 10 ай бұрын
#RahulNath, Hi Sir I have developed this task and its running on my machine,But when i publish on IIS Server its showing Swagger page and jobs are not storing and sending into database,I have watched so many solution nothing is working.Please can you help.Lot of setting i have trying.
@santanderhernandezcontador2875
@santanderhernandezcontador2875 8 ай бұрын
I have the same problem, can you help us? Rahul Nath #RahulNath @RahulNath
@tulsicreation2026
@tulsicreation2026 6 ай бұрын
its wrk in resolving circular reference issue.
@RahulNath
@RahulNath 6 ай бұрын
Sorry didn't understand?
@tulsicreation2026
@tulsicreation2026 6 ай бұрын
@@RahulNath want to say i had implemented your solution to resolv circular reference issue in my project , its resolve it.
@RahulNath
@RahulNath 6 ай бұрын
Great ok - glad it helped!
@shwetagopi5102
@shwetagopi5102 2 жыл бұрын
Where we have register Ihostedservice if in background task create a zip file. Right now we are register it in last of Configureservice
@RahulNath
@RahulNath 2 жыл бұрын
Sorry didn't understand your question. Can you provide more details Shweta?
@shwetagopi5102
@shwetagopi5102 2 жыл бұрын
@@RahulNath is there any order to add Ihostservice in DI container. My backgroud task is converting body to zip file
@RahulNath
@RahulNath 2 жыл бұрын
@@shwetagopi5102 What problem are you facing with the ordering? It shouldn't be a problem with starting the service
@segwitchannel2042
@segwitchannel2042 Жыл бұрын
will that affect the performance of the web api.
@RahulNath
@RahulNath Жыл бұрын
Depends on where you are hosting and what you are doing in the Background Tasks. If it's resource heavy you can decouple it to a Function/Lambda (depending on what your hosting platform is).
@albertocuevas7353
@albertocuevas7353 Жыл бұрын
What if I wanted to repeat a task at the beginning of each month
@RahulNath
@RahulNath Жыл бұрын
You could write some custom scheduling but I would choose Web Jobs/Azure Function with a cron trigger. Is that something that works for you?
@sarathbaiju6040
@sarathbaiju6040 2 жыл бұрын
Is any way to stop the backgroundjob task other than application shutdown? i am eargly waiting for your response
@RahulNath
@RahulNath 2 жыл бұрын
Sorry for the delay. Yes you can exit the loop and run only once or based on your conditions. the first job I show in the example closes down after first execution. If you can give more details on your use case I could suggest something.
@sarathbaiju6040
@sarathbaiju6040 2 жыл бұрын
@@RahulNath my use case is i created a background service to subscribe a kafka topic. As you said the while loop in the background service exist only when application goes to shutdown. My requirement is to create an endpoint or something that control the start and stop of background task. I don't know it is possible. If its possible please reply.
@RajendraKumar-zl2kx
@RajendraKumar-zl2kx Жыл бұрын
How to add multiple cron events inside a single background Service?
@RahulNath
@RahulNath Жыл бұрын
Best to use some external packages for that - Have a look at Quartz.net www.quartz-scheduler.net/ Hangfire etc www.hangfire.io/ Or if you can pull them out into serverless functions (Azure Functions, Lambda etc) if you are on cloud. Let me know if that helps.
@RajendraKumar-zl2kx
@RajendraKumar-zl2kx Жыл бұрын
@@RahulNath Thanks for the suggestion. I will try & let you know.
@user-dd3qx2pr8l
@user-dd3qx2pr8l Жыл бұрын
0:36
@RahulNath
@RahulNath Жыл бұрын
?
@miguelangeltaipemamani4840
@miguelangeltaipemamani4840 2 жыл бұрын
In webforms?
@RahulNath
@RahulNath 2 жыл бұрын
haven't tried yet. Did you get a chance to explore?
@developeratvcsvietnam150
@developeratvcsvietnam150 2 жыл бұрын
this is .net core 3.1 ? how to create in .net 6 bro?
@RahulNath
@RahulNath 2 жыл бұрын
Guessing most of it will be the same - What difficulties are you facing?
@Kasiux
@Kasiux 2 жыл бұрын
Every time I start my web API , the worker doesn't start with it... Of course I added it in program.cs
@RahulNath
@RahulNath 2 жыл бұрын
Hard to tell what might be the reason. Did you try adding a log statement in your background task startup?
@Kasiux
@Kasiux 2 жыл бұрын
@@RahulNath I added logs, breakpoints, database queries. It just won't be executed. The process is running under IIS express (rest API)
@Kasiux
@Kasiux 2 жыл бұрын
@@RahulNath okay, smh it's working now. But not instantly when I start the process but only after I did a first request to the backend over the frontend?! So if I just start my API, the worker won't instantly start. As I log in from the frontend a request will be sent to the API (just casual stuff) and then the worker starts. (After a request)
@RahulNath
@RahulNath 2 жыл бұрын
@@Kasiux Think it should work as soon as app launches. Can you create a minimal sample and send it to me and I can check - Details in the about page.
@madd5
@madd5 3 жыл бұрын
Can you try to mimic English or US accent? That way it would be less frustrating to listen to your videos and more people would join LOL
@RahulNath
@RahulNath 3 жыл бұрын
Haha, never thought that would be a reason for people not joining. Also can't tell if the people who have joined are because I don't have one. 😀
@shafiq.hussain.cscore
@shafiq.hussain.cscore 6 ай бұрын
Excellent
@RahulNath
@RahulNath 6 ай бұрын
Thank you so much 😀Hope you are liking the series bit.ly/asp-net-core-series
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 47 МЛН
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 97 МЛН
Waterfall Over Agile In 2023???
9:00
Continuous Delivery
Рет қаралды 57 М.
Fortnite mini Aquarium
0:40
RAWWFishing
Рет қаралды 33 МЛН
Тайка и Борщ | Телега "Легенда о Захаре" #еда
0:20
Легенда о Захаре
Рет қаралды 2,4 МЛН
Wonderful street food making skill
0:25
Fruit University
Рет қаралды 92 МЛН
Ужин для Леонида Каневского!
1:00
dacooker_
Рет қаралды 8 МЛН