Asynchronous call task

Asynchronous mainly used to enhance program performance, will increase the cost of the system (a new thread to perform asynchronous tasks).

It can be applied to time-consuming tasks, such as: when accessing the database (the application database and not on the same server), calls between service (service will be distributed on different servers).

About the asynchronous call does not return value

First define two methods

New tasks and enables asynchronous

transfer

Output

It is seen through this example two methods are performed simultaneously

Here are no return values ​​of reference example

The definition of a method named GetNum

By calling Task

Output

Likewise, also the two methods simultaneously

Guess you like

Origin www.cnblogs.com/zlwei23/p/10965773.html