© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2w ago•
61 replies
!!essmann

Async/Await question

intermediate
HttpServer2 httpServer = new HttpServer2();

httpServer.Start(); //If I don't await this, It won't block the main method. If I await it, I won't be able to do Console.ReadLine()

Console.ReadLine();
HttpServer2 httpServer = new HttpServer2();

httpServer.Start(); //If I don't await this, It won't block the main method. If I await it, I won't be able to do Console.ReadLine()

Console.ReadLine();

Note that .Start() is a method that simply starts listening on a port and handles requests, it has a Task return type.

Why would I ever for example do await httpServer.Start() when that certainly blocks the main method (where i'm calling it from) when I can just omit the await and carry on?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ async/await and parallelism
C#CC# / help
13mo ago
async/await and mutexes
C#CC# / help
2y ago
Learning Streamreader and async / await
C#CC# / help
4mo ago
Async await in minimal API
C#CC# / help
2y ago