Some small issues with synchronous asynchronous calls

Source: Internet
Author: User

As the project first truly touches, it uses both synchronous and asynchronous. Record a few personal bright:

. NET now offers a handy feature: async, await.

1. The method that is identified for async is an async method, and the return value of the class method can only be void or task<t>. (e.g.:task<bool> pingasync ();)

2. When the return value of the Async method needs to be obtained, it must be marked with an await at the call: it can be understood to wait for the return value of the Async method. (such as: var result = await _serverfacade.pingasync ();)

3. The method must also be an async method if the await is indicated internally.

Then, there is always a synchronization method on the top level, right? How to deal with it?

1. Asynccommand, you can bind an async method to the command

2. Async methods. Result (for example: var result = _serverfacade.pingasync (). Result;)

======================================================

For configureawait (BOOL)

Some small issues with synchronous asynchronous calls

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.