Zyrus
Zyrus
CC#
Created by Zyrus on 2/2/2024 in #help
✅ Help Regarding async Method Implementation.
Hi, I'm a beginner trying to automate some tasks using c# and selenium but i need help with using async methods. So, the scenario is, I have a foreach loop that runs 2 Methods (say A and B) a certain amount of times for each item in a list.(Method A and B cant run at the same time) I want it go as follows:
-Start-
-Method A- Called x1
-Method A- Finishes x1
-Method B- Called x1
---Loops--
-Method A- Called x2
{there is chance -Method B- can finishes here}
-Method A- Finishes x2
Wait for (-Method B- Finish x1)
-Method B- finishes x1 {if it didn't Earlier}
--Loops--
-Method A- Called x3
{there is chance -Method B- can finishes here}
-Method A- Finishes x3
Wait for (-Method B- Finish x2)
-Method B- finishes x2 {if it didn't Earlier}
--Loops--
-Start-
-Method A- Called x1
-Method A- Finishes x1
-Method B- Called x1
---Loops--
-Method A- Called x2
{there is chance -Method B- can finishes here}
-Method A- Finishes x2
Wait for (-Method B- Finish x1)
-Method B- finishes x1 {if it didn't Earlier}
--Loops--
-Method A- Called x3
{there is chance -Method B- can finishes here}
-Method A- Finishes x3
Wait for (-Method B- Finish x2)
-Method B- finishes x2 {if it didn't Earlier}
--Loops--
And so on.... Basically, i want Method B to start independently from Main and wait for it to finish before running it again on the next loop. How can I accomplish this? Any guidance would be appreciated :D I also cant figure out how can i use await inside the method since the browser task has various steps.
11 replies