✅ Basic http client get request
Hi why my code won't return any value
When i dont use Test method instead just using
it works normally
22 Replies
async void
is a no-no
Use async Task
And await the call, of courseokay that's work for me in this simple code, but now when im trying using so the GetServerTime method stays the same
how do i send more code than discord allows without nitro? sohuld i use pastebin or something like that?
$paste
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
The rule of thumb, though, is that
1. An
async
method needs to return a Task
or Task<T>
2. An async
method has to be await
ed
3. A method that await
s something has to be async
so my code looks like that
https://paste.mod.gg/kfiopaarqyuu/
BlazeBin - kfiopaarqyuu
A tool for sharing your source code with the world!
at line 35 i used GetServerTime method
but do you still have 'async void' somewhere?
no voids with async
only 2 tasks with async which are in sended code actually
show what calls Tavern
its other function which is void type
should i change all methods to Tasks?
Tavern is called by other method which is also called by other method ...
if it's void return type, how can you do
await Tavern
!?
yes, it needs to be Task/async 'all the way down'okay thanks
im creating simple console game, is something wrong if all methods will be tasks?
no, not if you want to be using async. It needs to start being async/Tasl from MAin
so going further all method calls has to be awaited right?
All async ones that aren't fire n forget
can i do that this way instead?
Avoid
.Result
because it can lead to deadlocks.what it actually means?
A deadlock is a situation, where two threads wait for each other, but both cannot continue execution until they got their answer from the other thread
my app doesnt use multiple threads
actually i just need to get time from server
im very begginer and just creating smple console game
should i worry about it right now?
Yes. I know it sounds tempting to just do it like that if it works, but as Mr. MultipleZ said, there is a rule of thumb you should follow
2. An async method has to be awaited