C
C#14mo 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
Tvde114mo ago
Those must be bad tutorials then. Please never use GetAwaiter().GetResult() async Task Main is fine!
Izagawd
IzagawdOP14mo ago
alright
Aaron
Aaron14mo ago
async mains were added after async was so they're probably just ancient habits
Kiel
Kiel14mo 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
JakenVeina14mo 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
IzagawdOP14mo ago
ill use async Task Main to look more professional 🗿
Accord
Accord14mo 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.
Want results from more Discord servers?
Add your server