© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
10 replies
Zyrus

✅ 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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Calling async method
C#CC# / help
4y ago
✅ [SOLVED] Need help with converting async method to a 'normal' method
C#CC# / help
3y ago
❔ Async Method with current code.
C#CC# / help
3y ago