CLR via C # Reading Notes 3-6 Comparison of APM and EAP (asynchronous programming model and event-based programming model)

Source: Internet
Author: User

APM: the asynchronous programming model (asynchronous programming model) beginxxx

EAP: The Event-base asynchronous pattern (Event-based programming mode) button. Click + = ........
EPM: The Event-base programming model

 

1. In essence, EAP also uses APM internally, but it only implements some encapsulation. Therefore, EAP will use more memory space (such as eventargs) and GC operations.

2. In simple cases, the PEM is generally a better choice and is also easier to use. Some restrictions on the PEM include:

1) the event must be registered before the Asynchronous Method is executed. Otherwise, the event may not be executed.

2) If you do not want to use an event, you must log off the event. (The event often causes memory leakage. If you are interested, you can check the events with weak references)

3) The static method and Singleton class should not use EPM. (I personally do not agree with this idea. The original Article in this book is:Static methods and Singleton classes cannot offer the EPM)

4) EAP cannot use catch to handle exceptions.

 

 

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.