About exception trapping for async & await (TAP) async Models

Source: Internet
Author: User

Before tap, to catch exceptions to a task in a thread, there are usually two ways:

1. Blocking: After the thread starts, at the appropriate time, call wait, or the WaitAll method.

2, non-blocking (recommended): When the task is set up, write the ContinueWith method of the task and catch the exception in the method.

For the tap era, if we were to capture a task with the Asyn keyword, the ContinueWith method would capture the failure. It is also not possible to register a global static method.

Blocking: Consistent with tap before.

Non-blocking: With

Await Task.whenall ()

Await t.wait ()

Await T.result, etc. can be.

The premise is to have an await keyword, which looks good, saves ContinueWith, but the problem is that await is only allowed to execute in the function of the ASYN flag, which can cause contagious problems for your program.

This can be said that the await keyword in fact and continuewith the role of similar, but simplified the wording, so that the program look more orderly, but the cost is not a bit large?

About exception trapping for async & await (TAP) async Models

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.