Cancel task in Grand Central Dispatch GCD with DispatchWorkItem in Swift Hindi tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024

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

  • @polu9132
    @polu9132 3 ปีที่แล้ว +8

    Sir, you are a real gem for the iOS developers. 🙏

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

      Thank you 😊 I am glad the video was helpful. Plz do ask questions on this topic and do share the video with your iOS group

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

      @@CodeCat15 Sir pls make more videos on concurrency on iOS like Operation Queues and some more advanced concepts if possible. Thanks.🙏

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

      Sure will do Polu

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

    Hey Ravi, I don't have words for how to thank you. Just ming blowing bhava!

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

      Akshay, welcome bhava, tula kahi doubts asel tar te pan vichar ani tuja iOS group sobat pan he channel share kar 👍

  • @GovindSingh-vf7ff
    @GovindSingh-vf7ff 3 ปีที่แล้ว +1

    Trust me this is my first comment in any ios development video , amazing explanation

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

      Welcome to the channel Goving and thank you for taking time and commenting on the video, I am glad the contents of this channel are helpful :)

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

    Brilliancy ,bhai please do more and more videos ,,,,

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

      Threading playlist link: th-cam.com/play/PLb5R4QC2DtFuSE3wpJAqvFRbal5-7sAwr.html
      Hope it helps

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

      @@CodeCat15 ya bhai making notes out of all videos from the playlist... Thanks bahi really, har baar interview ma a topic pareshaan karta tha ....now it will not...

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

    Great topic with great example and explanation! Very helpful.

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

      Thanks Dhaval, glad the content is helpful. Do share the video with your iOS group and feel free to ask questions on the topic

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

    Excellent explanation. These videos are fulfilling the gap for me of not being trained professionally as trainee and using random techniques, internet solutions to solve problems in task deadline and later sit and regret for writing bad code and waste further more time to clean the previous code. I am feeling a technical detox by watching several of these videos on daily basis. Kudos to the creator. #CheersToCodeCat15

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

      I like the term technical detox, funny thing is implementing clean code takes a little time but has long term benefits specially with regards to change requests, we surely don't want our codebase to be like a card house, you remove or replace one card and the entire house collapses.

  • @NeerajKumar-tx1qo
    @NeerajKumar-tx1qo 3 ปีที่แล้ว +1

    Bhai ekdum mst sikhato ho, thank you🙏🙏🙏

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

      Thanks Neeraj, koi question raha ye topic pe to please puchna zaroor aur aapne iOS group mai bhi is video ko share karna :)

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

    yes bro I learned new concept DispatchWorkItem from this video . Thank you :-)

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

      Am glad this was helpful 👍

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

    Awesome Video
    Thanks for share brother

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

    Great content sir. Grateful to access such content for free.

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

    Very useful content.. keep rocking

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

      Thanks a lot Sharmi

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

    clear all my doubt Thank you sir.

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

      You are most welcome

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

    Ravi, you are Super.

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

      Thank you Ashish :)

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

    Thank you for this video.

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

    Very informative video Ravi....One doubt -> If we can cancel the task in GCD then what is the use of OperationQueue over it?

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

      i made a video about this, please check it out and let me know if you have any queries
      video link: th-cam.com/video/JuFAW7y8lp0/w-d-xo.html

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

      @@CodeCat15 Thank you Ravi🙂

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

    Way of explaining 🙏🙂

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

    Superb sir 👌👌

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

    Very well done

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

    I Think in iOS 13 there is a debounce api but thanks for the video, i learned how it works

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

      Indeed Somendra, using the combine framework we surely can implement debounce, but its from ios 13 onwards wish there was backward compatibility but its alright we have DispatchWorkItem to the rescue. Please feel free to ask questions on the topic and do share the channel with your iOS group

  • @PrashantKumar-fg4tg
    @PrashantKumar-fg4tg 3 ปีที่แล้ว

    Thanks for this information. Please create a video on operation queue also

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

      Hello Prashant, welcome to the channel I am glad this video was helpful. Please do feel free to ask questions on this topic and yes a video on operation queue and other threading concepts are on their way very soon

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

    Bhai ek request hai apko code font is like android bro so change it to natural iOS. Thanks for content it was worthfull.

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

      Mai initially asp.net developer tha aur hum visual studio use karte the jiska default font hai consolas aur abhi 10 saalo se vahi font ki adat ho chuki hai koi bhi editor ho meri font family fixed hai, maine try kiya tha xcode ka default font but then jama nahi mujhe sorry agar font ka vajaha se koi dikkat aai aapko 🙏

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

      @@CodeCat15 Nahi bro I also had experience with Visual studio and remember this font haha 😛. no issues.

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

    Awesome 😎

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

    informative

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

    👌👌👌

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

    Brother
    I did not get this can someone please explain me.
    How DispatchWorkItem is cancelling the task? isCancellled bool which we checking here in for loop this bool variable is used for cancelling this for loop task (even cancelling by developer using break) not workitem.

  • @ajaykumar-kq2wf
    @ajaykumar-kq2wf 2 ปีที่แล้ว +1

    Can we cancel api call in dispatchworkitem?

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

      You can cancel the work item itself which will ultimately cancel whatever workItem it was intent to do
      What this means is the API call which is already done to the server that call may happen and say before you receive the response if you cancel the workItem then in that case the response will be ignored.
      In theory I believe this is what should happen but you can try this out and confirm if this works as per your given usecase.

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

    nice vide0

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

      Thank you :)

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

    One difference between dispatch work item and operation queue is -
    Dispatch work item can execute and cancel only one operation, whereas an operation queue can execute multiple operations concurrently and cancel together all if needed using the cancelAllOperations() method.
    Is that correct ?

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

      Apple recommends that you should always use the highest level of abstraction, which means we should be using operation queue and not GCD which is a low level api, but due to convince many devs including me go for gcd directly.
      Having said that, operation queue holds its place coz it can handle dependencies and you can pause and yes cancel all operations, operation queue does things more object oriented way than GCD and we have more control over what we are trying to do with operation queue than GCD

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

    Why are we calling the API on main queue?

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

      Hey Keertika, url session internally calls the api on a background thread on its own so we don’t really have to specify or use a dispatch queue. If you watch the serial api call video there you can see this behavior
      Video link: th-cam.com/video/II7bJmC64IY/w-d-xo.html
      Let me know if that answers your question and if not plz feel free to ask more.

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

      @@CodeCat15 Thank you sooo much 😊

  • @Sameerkhan-pu7kn
    @Sameerkhan-pu7kn 3 ปีที่แล้ว

    Same task can achieve by published cause publishe has time & cancel property.

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

      That’s more swiftui and am yet to explore that world of swiftui but it will be very interesting to see that and how it works or how it’s different from dispatchWorkItem I’ll make a note of this Sameer thanks for sharing ☺️

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

    hello, I really enjoy your video.. so informative.. and to the point. hats off to you.
    It would be really helpful if you create a video on the topic of the different combination of sync and async block using different dispatch queues(serial, concurrent, main &global). I really got confused of the flow in some of the questions like below,
    func testx(){
    defer {
    print("--testx--")
    }
    DispatchQueue.main.async {
    print("testx")
    }
    print("--testx")
    }
    func testy(){
    defer {
    print("--testy--")
    }
    DispatchQueue.main.async {
    print("testy")
    }
    print("--testy")
    }
    func test(){
    print("01")
    testx()
    print("02")
    testy()
    print("03")
    }
    test()
    this will print:
    01
    --testx
    --testx--
    02
    --testy
    --testy--
    03
    testx
    testy
    here the dispatch asyn block executed at last why that so?

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

      Yep, I also face the similar problem in understanding this topic. @CodeCat please answer

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

      Let me make a video on this as comments could get a little lengthy

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

      ​@@CodeCat15 sure, that'll be great.