What is. NET asynchronous mechanism (delegate delegate)

Source: Internet
Author: User
Tags thread

Before reading the following knowledge, I already think you already have C # Foundation, including simple delegate knowledge; Code is developed using VS2008, but will be written in the. Net Framework 2.0 (C Sharp)

What is. NET asynchronous mechanism?

Before we explain this topic, let's look at the synchronized program, which is our usual Hello World program.

Code 1:

1 class Program
2 {
3 static void Main (string[] args)
4 {
5//view current thread ID, whether threads in thread pool
6 Console.WriteLine ("1,thread Id:#{0},is poolthread?{ 1} ",
Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread);
7
8 Asynctest test = new Asynctest ();
9 String val = Test. Hello ("Andy Huang");
Console.WriteLine (val);
Console.ReadLine (); Let the black screen wait, not directly off.
The public
class Asynctest {# public
string Hello (string name)
19 {
20//view current thread ID, whether threads in thread pool
Console.WriteLine ("2,thread Id:#{0},is poolthread?{ 1} ",
Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread);
Return "Hello:" + name;
24}

Figure 1

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.