✅ public static async Task Main instead of public static void Main for dsharpplus setup?
In tutorials I see that they use void, and they call an async method using GetAwaiter().GetResult(). why not just use async Task Main instead? would there be some issues or something?
7 Replies
Those must be bad tutorials then. Please never use GetAwaiter().GetResult()
async Task Main is fine!
alright
async mains were added after async was
so they're probably just ancient habits
I recall a couple people I knew who worked with Discord bots complaining about something with async mains garbling or otherwise mucking up stacktraces or something like that, I'm sure that's not the case anymore but maybe that's why some tutorials still used it
inside
void Main()
is one of the few scenarios where .GetAwaiter().GetResult()
is completely valid
that's essentially what the runtime does for you when you use async Task MainAsync()
ill use async Task Main to look more professional 🗿
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.