For Asynchronous understanding, asynchronous

Source: Internet
Author: User

For Asynchronous understanding, asynchronous

Previously, I was confused about Synchronous methods and asynchronous Methods Using async and await. I think what is the difference between the asynchronous and synchronous Methods waiting for execution results? Their execution order is the same?

Don't all need to wait for execution results? Today, I flipped through C # advanced programming to figure out the difference. The async and await Asynchronization won't block the thread.

First, let's talk about the differences between the synchronous method and the Asynchronous Method. For example, if a web site loads some network resources and uses synchronous requests, the user interface of the web site will be blocked,

The method is used to call the network of the resource and analyze the result. The time required to complete these calls depends on the network speed and the current workload of the server. It is unpleasant for users to get disconnected and wait for a period of time.

So use Asynchronous call. Asynchronization can avoid blocking, and more things can be done during this period. However, Asynchronization has a defect. Compared with synchronization, it is full of uncertainty about the process of the program, and the order may be reversed.

In some scenarios, for example, when multiple asynchronous methods are called, they are dependent. The subsequent asynchronous methods must use the results of the previous Asynchronous Method, we need to call these asynchronous methods in order,

In this case, the async and await keywords are used to wait for the execution result, but it does not block the thread.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.