🔥 Don't use Task.WhenAll, it may not be efficient enough!

Поделиться
HTML-код
  • Опубликовано: 27 янв 2025

Комментарии • 20

  • @researcher_m
    @researcher_m 4 месяца назад

    Thank you for your useful tips

    • @sa-es-ir
      @sa-es-ir  4 месяца назад

      Happy you like it

  • @nztzn
    @nztzn 5 месяцев назад +2

    Thank you for the content ❤

    • @sa-es-ir
      @sa-es-ir  5 месяцев назад +1

      Glad you like it, I would appreciate it if you share this video on your network🙏

  • @sergeantskeleton7392
    @sergeantskeleton7392 5 месяцев назад

    Great!

    • @sa-es-ir
      @sa-es-ir  5 месяцев назад

      Glad you like it, I would appreciate it if you share this video on your network🙏

  • @Happyprogrammer-p6z
    @Happyprogrammer-p6z 5 месяцев назад

    Perfect

  • @rafazieba9982
    @rafazieba9982 5 месяцев назад +5

    Change the order of tasks in the final list to "new List { taskThree, taskTwo, taskOne }" to see why it doesn't work the way you want it to. It will wait for three seconds before it cancels the "CancelationToken".

    • @igormelnikov5166
      @igormelnikov5166 5 месяцев назад +1

      Yes, it can be improving by dequeueing waiting each task via WaitAny mutiple times, but it can increase memory and CPU allocation.

    • @sa-es-ir
      @sa-es-ir  5 месяцев назад

      In the worst case, it just behaves like Task.WhenAll()!

    • @igormelnikov5166
      @igormelnikov5166 5 месяцев назад +1

      @@sa-es-ir U didnt get what he want to say, it is not about worst case, it is about reordering await affects execution time in you approach, if last task will wait 1 sec before exeption, you still will wait 3 sec because of first task 3 sec delay

    • @sa-es-ir
      @sa-es-ir  5 месяцев назад

      @@igormelnikov5166 Yes your scenario is perfectly fine and can happen because there is no way to know task priorities, my point is, even in worst case (taking 3 sec) is the same Task.WhenAll which always takes 3 sec. Am I correct?

    • @igormelnikov5166
      @igormelnikov5166 5 месяцев назад +1

      @@sa-es-ir There is a way to respect task priorities, read my first comment. Worst cases are same in all soulutions ofcourse. But in average solutions have different time

  • @حسینمحسنی-ب7ق
    @حسینمحسنی-ب7ق 5 месяцев назад

    ❤❤❤❤❤❤❤❤❤❤❤

    • @sa-es-ir
      @sa-es-ir  5 месяцев назад

      Thank you baba♥

  • @nitishkumar-dt2tx
    @nitishkumar-dt2tx 5 месяцев назад

    Awesome explanation

    • @sa-es-ir
      @sa-es-ir  5 месяцев назад

      Glad you like it, I would appreciate it if you share this video on your network🙏