C
C#•2y ago
MayoWAA!

My Terminal outputs nothing

For some reason when I print an output from an Api or Nuget package it returns nothing.
11 Replies
Angius
Angius•2y ago
I mean
Angius
Angius•2y ago
Angius
Angius•2y ago
Ah, I see the 2nd screenshot Well, it's async And you're not awaiting it So the code runs, but the app doesn't wait for it to be done running and just exists
MayoWAA!
MayoWAA!OP•2y ago
I'm actually stupid, sorry
Angius
Angius•2y ago
Show your solution, we'll see 😛
MayoWAA!
MayoWAA!OP•2y ago
i just removed the await from the code and it worked
MayoWAA!
MayoWAA!OP•2y ago
it was just meant to be a quick package test so everything was kinda hacky
Angius
Angius•2y ago
Uh, yeah, do not remove it .Result is the hacky way if anything What you want is make GetMetadata method async Task instead of async void Then make your Main method async Task instead of void And add await to your GetMetadata() call
MayoWAA!
MayoWAA!OP•2y ago
ohhh!!! i genuinely didn't think of that I forgot the main method doesn't have to be void I was gonna ask this question on stack overflow but I'm happy I asked it here instead cause I woulda gotten pumbled
Angius
Angius•2y ago
To be more precise, the main method can be either void, int, async Task, or async Task<int> https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/main-command-line#main-return-values
MayoWAA!
MayoWAA!OP•2y ago
thanks
Want results from more Discord servers?
Add your server