. NET Async functions exist limitations

Source: Internet
Author: User

This document is excerpted from CLR Via C # version fourth.

The following limitations exist for asynchronous functions:

1. The main method cannot be used to translate the application into an asynchronous function. In addition, constructors, property accessor methods, and time accessor methods cannot be transformed into asynchronous functions.

2. Async functions cannot use any out or ref parameters.

3. You can no longer use the await operator in catch,finally or unsafe fast.

4. You can not get a lock that supports county ownership or recursion before waiting for the operator, and releases it after the await operator. This is because the code before the await is executed by one thread, and the subsequent code is executed by another thread. Using await in a C # lock statement will cause the compiler to make an error. If you explicitly call Minitor's Enter and Exit methods, the code can compile, but Monitor.Exit throws a synchronizationlockexception at run time.

5. In a query expression, the await operator can only be used in the first set expression of the initial from clause, or in a set expression in a join clause.

. NET Async functions exist limitations

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.