C # follow a stupid play with asynchronous task Combat (i)

Source: Internet
Author: User

I. Introduction of the Course

This sharing course belongs to the first part of the "C # Advanced programming practical Skills Development Treasure Course Series", the second program will be a practical project on some of the more practical aspects of C # Advanced programming skills to share with you to learn, and constantly collect, organize and improve this series of courses!

This advanced series of courses is suitable for the following groups:

1, have a certain NET development foundation and have a certain understanding and understanding of multithreading technology.

2, like a stupid dry to share the course of children's shoes.

I hope that you choose a stupid C # advanced Programming Skills Development Course series, according to their own circumstances to choose, because this course is not 0 basic teaching courses series, so say. NET Foundation poor to the point of no friends, that stupid suggest you still first "learn" some basic knowledge of good net, and then in C # follow a stupid "play" to play asynchronous task Combat!

If you are also interested in this share of the "C # follow a stupid play with asynchronous task Combat" course, then please follow the stupid study together.

Needless to say, directly on dry goods, we do not produce dry goods, we are just dry goods porter.

Ii. explanation of the meaning of concept name

2.1. What are the differences and connections between multithreading and Asynchrony?

First, the difference:

1), the asynchronous scope is when I am required to perform I/O operations. I/O operations include direct files, read and write to the network, and cross-process calls such as database operations, Web Service, HttpRequest, and. NET Remoting.

2), the application of the thread is the kind of long-time CPU operations, such as time-consuming graphics processing and algorithm execution.

But often because of the simple and consistent use of threading programming, many friends tend to use threads to perform long-time I/O operations.

Second, contact:

1), multithreading, and asynchronous operations can both achieve the purpose of avoiding the call thread blocking, thus improving the software's responsiveness.

2), the nature of Asynchrony is also multi-threading.

For details on the differences and links between the two, recommend the following blog:

The difference between multithreading and Asynchrony in C #-how to correctly apply asynchronous programming technology

Third, asynchronous task real-instance sharing

3.1), C # uses asynchronous task implementation queries to wait for loading effects.

3.2), C # Use task to achieve multi-tasking batch processing.

3.3), C # How to gracefully convert the synchronization method into an asynchronous method.

3.4), C # How to synchronously get the result of an asynchronous event callback.

1), Solution One: asynchronous blocking gets the result of an asynchronous event callback by means of the task+autoresetevent mechanism.

2), solution Two: through Task +cancellationtokensource (after class please think for yourself)

Iv. Summary

If you want to learn more about the real-life skills of a moron using asynchronous Task technology in the project, we recommend that you learn about the Webapi+task+websocket of C # Combat skills that you shared earlier. As the saying goes: Master led the door to practice in the individual, I hope everyone in the road of learning has been continued!

Five, the source of online learning and demonstration

C # follow a stupid play with asynchronous task Combat (i)

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.