C
C#16mo ago
Izagawd

✅ 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
Tvde1
Tvde116mo ago
Those must be bad tutorials then. Please never use GetAwaiter().GetResult() async Task Main is fine!
Izagawd
IzagawdOP16mo ago
alright
Aaron
Aaron16mo ago
async mains were added after async was so they're probably just ancient habits
Kiel
Kiel16mo ago
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
JakenVeina
JakenVeina16mo ago
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()
Izagawd
IzagawdOP16mo ago
ill use async Task Main to look more professional 🗿
Accord
Accord15mo ago
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.

Did you find this page helpful?