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

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ส.ค. 2024
  • 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...
    🐦Twitter - / rahulpnath
    📸Instagram - / rahulpnath
    🎥 Recording Setup and Workflow - www.rahulpnath...
    Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

ความคิดเห็น • 189

  • @BM-jy6cb
    @BM-jy6cb ปีที่แล้ว +1

    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

  • @BM-jy6cb
    @BM-jy6cb ปีที่แล้ว

    Now 23k subscribers, but this channel deserves so much more!

  • @shanmuka16
    @shanmuka16 ปีที่แล้ว +1

    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

  • @keerthang5557
    @keerthang5557 3 ปีที่แล้ว +4

    Excellent Tutorial Rahul, eagerly waiting for part 2!

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +2

      Glad you like it Keerthan and thank you for this video suggestion!

  • @shashikantpawar7069
    @shashikantpawar7069 3 ปีที่แล้ว +2

    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.

  • @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

  • @TellaTrix
    @TellaTrix 3 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      Glad to hear that

  • @anuragnigam55
    @anuragnigam55 2 ปีที่แล้ว +5

    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.

  • @sachinichathurika9507
    @sachinichathurika9507 3 ปีที่แล้ว +2

    Simple and very clear tutorial. Thank you for the great information.

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      Thank you Sachini. Do check out the full series here th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html
      I am sure you will like them too! Do let me know in case you get to watch them 😀

  • @pramod.kulkarni9607
    @pramod.kulkarni9607 ปีที่แล้ว +1

    Amazing Tutorial Rahul.

    • @RahulNath
      @RahulNath  ปีที่แล้ว +1

      Glad you found it useful. The full series is here bit.ly/asp-net-core-series

  • @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 ปีที่แล้ว +1

      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 😀👍

  • @xbenchers1116
    @xbenchers1116 3 ปีที่แล้ว

    One of my favorite on TH-cam.
    Thank you Sir for the great explanation.

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว

      So nice of you. And you can call me Rahul 😀

  • @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

  • @efeamioku3220
    @efeamioku3220 2 ปีที่แล้ว +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 ปีที่แล้ว +1

      Glad to hear that! Thank you Efe 😀

  • @shovonku
    @shovonku ปีที่แล้ว +1

    Your presentation style is very simple and to the point. Keep up the good work, Rahul.

    • @RahulNath
      @RahulNath  ปีที่แล้ว +1

      Glad you like it. Hope you are enjoying the series bit.ly/asp-net-core-series

  • @deivamanidhandabani9505
    @deivamanidhandabani9505 2 ปีที่แล้ว +1

    Great Lesson Rahul keep doing the same.

    • @RahulNath
      @RahulNath  2 ปีที่แล้ว +1

      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

  • @northshorepx
    @northshorepx ปีที่แล้ว

    Excellent Video!!! Thank you

    • @RahulNath
      @RahulNath  ปีที่แล้ว

      You are welcome! Hope you are enjoying the series bit.ly/asp-net-core-series

  • @shafiq.hussain.cscore
    @shafiq.hussain.cscore 8 หลายเดือนก่อน

    Excellent

    • @RahulNath
      @RahulNath  7 หลายเดือนก่อน

      Thank you so much 😀Hope you are liking the series bit.ly/asp-net-core-series

  • @sufyannisar
    @sufyannisar 3 ปีที่แล้ว +1

    Simple and to the Point! Great Tutorial!

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว

      Glad you liked it Sufyan! do check out the full playlist here th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html

  • @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

  • @praveenthakur6908
    @praveenthakur6908 ปีที่แล้ว

    Great explanation Rahul👍👍👍

    • @RahulNath
      @RahulNath  ปีที่แล้ว

      Glad you like it Praveen. Hope you are enjoying the series bit.ly/asp-net-core-series

  • @hadirezaee7292
    @hadirezaee7292 3 ปีที่แล้ว +1

    like always, short, simple and usefull

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว

      Thank uou Hadi !

  • @manjinderbajwa1468
    @manjinderbajwa1468 2 ปีที่แล้ว +1

    Excellent keep it up

    • @RahulNath
      @RahulNath  2 ปีที่แล้ว

      Thanks a lot! Hope you are liking the 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

  • @parwejp
    @parwejp 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Thank you and good idea - will try and add testing too in it.

  • @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 th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html

  • @navaneethakrishnan1532
    @navaneethakrishnan1532 ปีที่แล้ว

    nice Explanation Rahul

    • @RahulNath
      @RahulNath  ปีที่แล้ว

      Happy you liked it. Do check out the full series here bit.ly/asp-net-core-series

  • @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

  • @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

  • @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

  • @harmeetchandok7824
    @harmeetchandok7824 3 ปีที่แล้ว +1

    Thanks for this video

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว

      Most welcome Harmeet. Do check out the other videos in this series th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html

  • @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?

  • @lamhongbac
    @lamhongbac 6 หลายเดือนก่อน

    Cảm ơn bạn!

  • @aravindmaestro1492
    @aravindmaestro1492 3 ปีที่แล้ว

    Really helpful.... thanks for uploading some great .net contents..easily understandable...waiting for more such content . Thanks Rahul 😊

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว

      Thank you Aravind. Do check out the full series here if you haven't already th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html
      Feel free to let know if you have specific topic suggestions.

  • @Latif127
    @Latif127 2 ปีที่แล้ว

    Very helpful tutorial. Thank you.

    • @RahulNath
      @RahulNath  2 ปีที่แล้ว

      Glad it was helpful Abdul!

  • @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

  • @sonalirane4667
    @sonalirane4667 2 ปีที่แล้ว +1

    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.

  • @ksdvishnukumar
    @ksdvishnukumar 3 ปีที่แล้ว

    As usual explained very well Rahul...Thanks a ton bro...👍

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      Thank you 😀 So happy these help and for letting me know.

  • @ivanpesenti1138
    @ivanpesenti1138 3 ปีที่แล้ว

    As usual amazing video Rahul. Thanks for your work and time 😄

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      Thank you Ivan! These comments make it worth my time, thank you for watching.

  • @shirazeditar5006
    @shirazeditar5006 ปีที่แล้ว

    👍

  • @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

  • @bloopers2967
    @bloopers2967 3 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      Thank you 😀 For logging th-cam.com/video/dxBlBltEDRs/w-d-xo.html
      Does that help? What specifically are you looking for with collections?

    • @bloopers2967
      @bloopers2967 3 ปีที่แล้ว +2

      @@RahulNath like how to use non- generic collections in a real world scenario

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      @@bloopers2967 Mmm that is interesting. I usually don't use that much. What scenario are you using non-generic currently for?

    • @bloopers2967
      @bloopers2967 3 ปีที่แล้ว +1

      @@RahulNath 😂😂for solving competitive coding questions

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      @@bloopers2967 Haha ok, one more reason to hate such questions 😂🤣

  • @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

  • @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

  • @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 ปีที่แล้ว +4

      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

  • @abhishekks6782
    @abhishekks6782 3 ปีที่แล้ว +1

    waiting for In Part 2, please give example with some real time examples.

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      Yes, it's on the list! Thank you for the prompt 😀

  • @ElyinAnuarSarriaMontenegro
    @ElyinAnuarSarriaMontenegro 11 หลายเดือนก่อน

    Hola buenas
    Un vídeo de worker services sería de mucha ayuda
    Saludos

  • @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

  • @tobbyechonga2461
    @tobbyechonga2461 2 ปีที่แล้ว

    Thank you very helpful.

    • @RahulNath
      @RahulNath  2 ปีที่แล้ว

      Glad it was helpful Tobby! Do check out the full series here th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html

  • @diegomelgar2696
    @diegomelgar2696 11 หลายเดือนก่อน +1

    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  11 หลายเดือนก่อน +1

      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 11 หลายเดือนก่อน +1

      @@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  11 หลายเดือนก่อน +1

      @@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 th-cam.com/play/PL59L9XrzUa-ku74pfBcy4f3tigwfzGUrG.html
      For critical processing I wouldn't depend on Background Tasks.

    • @diegomelgar2696
      @diegomelgar2696 11 หลายเดือนก่อน

      @@RahulNath thanks, will check on that!

  • @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

  • @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 ปีที่แล้ว +1

      @@RahulNath Not facing any issue as such but curious to see how you will handle it.

    • @RahulNath
      @RahulNath  2 ปีที่แล้ว +1

      @@MrSachintelalwar Have it in my list, yet to get to it 😀

  •  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 ปีที่แล้ว +1

      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/

  • @JitheshChandrasekharan
    @JitheshChandrasekharan 2 ปีที่แล้ว +1

    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.

  • @josephrozario6237
    @josephrozario6237 2 ปีที่แล้ว +1

    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 ?

  • @ershadnozari
    @ershadnozari 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Thank you Ershad and happy you like it. Did you find anything interesting on this channel? th-cam.com/users/Azure4Everyone
      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.

  • @andrewreiser3584
    @andrewreiser3584 2 ปีที่แล้ว +1

    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?

  • @hector9079
    @hector9079 3 ปีที่แล้ว

    Muy bueno

  • @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 ปีที่แล้ว +1

      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  ปีที่แล้ว +1

      @@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!

  • @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

  • @BlalKhalidTech
    @BlalKhalidTech 5 หลายเดือนก่อน +1

    Hello,What if we want run background service even the application is close?

    • @RahulNath
      @RahulNath  5 หลายเดือนก่อน +1

      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?

  • @habbabbutt3447
    @habbabbutt3447 2 ปีที่แล้ว +1

    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

  • @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.

  • @rohandeshpande5850
    @rohandeshpande5850 3 ปีที่แล้ว +1

    could you please make videos on Razor pages and Core Blazor

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      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 😀

  • @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

  • @mdaslamknl
    @mdaslamknl ปีที่แล้ว

    Good
    Why don't you give real life scenerio
    Thanks

  • @santanderhernandezcontador2875
    @santanderhernandezcontador2875 9 หลายเดือนก่อน +1

    How do you deploy in IIS?
    do you have an example?

    • @RahulNath
      @RahulNath  9 หลายเดือนก่อน

      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

  • @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

  • @tulsicreation2026
    @tulsicreation2026 7 หลายเดือนก่อน

    its wrk in resolving circular reference issue.

    • @RahulNath
      @RahulNath  7 หลายเดือนก่อน

      Sorry didn't understand?

    • @tulsicreation2026
      @tulsicreation2026 7 หลายเดือนก่อน

      @@RahulNath want to say i had implemented your solution to resolv circular reference issue in my project , its resolve it.

    • @RahulNath
      @RahulNath  7 หลายเดือนก่อน

      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

  • @user-dd3qx2pr8l
    @user-dd3qx2pr8l ปีที่แล้ว

    0:36

  • @oggyoggy3033
    @oggyoggy3033 ปีที่แล้ว

    #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.

  • @roslanbainal5914
    @roslanbainal5914 3 ปีที่แล้ว

    this method can be used for sending
    email automatically for specific user which is inactive user more than 6 month?

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      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 3 ปีที่แล้ว +1

      @@RahulNath thank you sir for your explanation 👍

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      @@roslanbainal5914 No probs Roslan. And you can call me Rahul 😀

  • @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?

  • @RajendraKumar-zl2kx
    @RajendraKumar-zl2kx ปีที่แล้ว

    How to add multiple cron events inside a single background Service?

    • @RahulNath
      @RahulNath  ปีที่แล้ว +1

      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.

  • @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.

  • @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).

  • @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 ปีที่แล้ว +1

      @@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.

  • @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?

  • @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 ปีที่แล้ว +1

      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. 😀

  • @fahadnoor2579
    @fahadnoor2579 3 ปีที่แล้ว +1

    Excellent

    • @RahulNath
      @RahulNath  3 ปีที่แล้ว +1

      Thank you so much Fahad😀 Make sure to check out the other videos in this series th-cam.com/play/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP.html