AntiHeroKid
AntiHeroKid
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
like task 1 is download images task 2 is download videos task 3 is upload whatever data you currently downloaded you would want task 3 i.e. uploading to happen once task 1 and task 2 are completed.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
you still need to make control flow decisions, and make sure the program runs predictably. That's where await is helpful.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
hugs kouhai
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
if they were moved before await Task 1, then yes they would run before i am 100 % sure.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
when we await Task 1 we didn't even create rest of the tasks. So they were not even in the picture.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
All we are saying wait for Task 2 to complete before moving forward in the code. Task 3 and Task 4 may have already be finished.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
They run asynchronously only.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
Bruh as @Kouhai pointed out my mistake, they won't be sequential.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
@Shinigami do you understand better now?
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
as Kouhai pointed out my mistake.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
i used to be confused about this as well. But the thing is await here is helping us to run the code sequentially in the sense that it is going to wait for secondTask to complete (even though thirdTask and fourthTask may have compeleted already)
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
but the await firstTask before them is like, as Kouhai said. Please wait for the firstTask to complete before moving forward.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
Task secondTask = ConsoleWithDelayAsync("Task 2",150); Task thirdTask = ConsoleWithDelayAsync("Task 3",9); Task fourthTask = ConsoleWithDelayAsync("Task 4",80);
They have began running concurrently.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
The moment you created them
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
if you don't use await the tasks have already began executing concurrently.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
focus on await
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
@Shinigami Just remember what kouhai said
You can think of await as currently stop "here" until the task finishes
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
Sorry you are correct. It just pauses the main thread.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
oh sorry...yeah so....You see. They are asyncronous yes but using await makes them run sequentially.
46 replies
CC#
Created by Shinigami on 8/24/2024 in #help
Why does Task 1 prints first instead of Task 3 - Async & Await
But aren't all of your tasks inside firstTask?
46 replies