First Stage: Synchronization
All operations are executed in sequence, and the function is called before the next step is completed.
Phase II: Fully asynchronous
Problem: In a synchronous operation, some functions perform relatively time-consuming, resulting in reduced overall usability of the program and poor user experience.
Workaround: Perform the next step asynchronously, without waiting for the function to return. Wait until the function execution is triggered by some mechanism, so that the corresponding result to continue processing.
Phase three: Partially asynchronous
Issue: In full async, there may be situations where some operations can take too long, or an asynchronous function that has an error in execution that causes an inability to return normally. Causes the caller to consume some asynchronous trigger mechanism's resources, especially in the large-scale software, can cause the server performance to waste, the performance is reduced.
Workaround: Set the time to wait for an asynchronous operation by partially asynchronously, and if the timeout returns an error, release the resource for the asynchronous trigger mechanism.
Example: WCF
======================================
Asynchronous mechanism
Thought:
Another thread is started, which causes the master thread (usually the UI thread to be unblocked) to notify the result through inter-threading communication.
. NET:
Classification:
APM Mode (asynchronous programing model) other
EAP Mode (event-based Asynchronous Pattern) event-driven
Compare http://www.cnblogs.com/dctit/archive/2013/01/13/2853853.html
Example:
Apm:beginxxx/endxxx
Eap:xxxasync/xxxcomplete and Eventargs/eventhandler
In Java:
Asynctask; and other asynchronous implementations by threading
MessageQueue + Looper + Handler
NIO (New IO) Selector+socketchannel
Schema note [i]: synchronous vs. asynchronous