async vs sync
synchronous (sync) - you can only execute one thing at a time
asynchronous (async) - you can execute multiple things at the same time
async vs sync
synchronous (sync) - you can only execute one thing at a time
asynchronous (async) - you can execute multiple things at the same time
async await vs synchronous c#
Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");
string urlContents = await getStringTask;
VS
string urlContents = await client.GetStringAsync();
Answer:
Calling await client.GetStringAsync() yields the execution to the calling method,
which means it won't wait for the method to finish executing,
and thus won't block the thread. Once it's done executing in the background,
the method will continue from where it stopped.
If you just call client.GetString(), the thread's execution won't continue
until this method finished executing,
which will block the thread and may cause the UI to become unresponsive.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us