Answer the question
In order to leave comments, you need to log in
Why is Async Await needed in C#?
I don’t understand why to use async await, I re-read many articles, but I didn’t understand the meaning.
After all, the result is the same if the method is not made asynchronous.
Or, is it only necessary to not freeze the main thread, but at the same time not continue execution until the secondary thread is completed?
Answer the question
In order to leave comments, you need to log in
Asynchrony is about performance concurrency. Multithreading is about multiple threads.
Asynchrony - you woke up, put the kettle on, went to the shower. Heard a squeak - returned, made tea and continued to brush his teeth.
Multithreading - it's you who woke up, went to the shower, and your girlfriend put the kettle on.
This is a sugar that freezes the current execution position in the method while the asynchronous method is running. It replaces creating a thread, starting a thread, calling a callback when the thread ends. It also allows you not to highlight the underlying code in the coolback method.
async / await is needed for optimal use of system resources, there are two types of tasks - I / O tasks and multithread tasks, and so with IO operations it makes no sense to keep the current thread, you can let those who need it use the CPU resources, and so before you had to use IAsyncResult , it was inconvenient, now there is syntactic sugar for it and a unified approach to working with asynchrony and multithreading
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question