c# 進程(一)

來源:互聯網
上載者:User

標籤:不同   for   manage   method   多個   current   man   int   多線程   

1、進程,進程和多線程的概念:

進程:一個程式運行時所有資源的統稱。

線程:每一個響應執行流就是線程。(做不同的事情)

多線程:多個線程同時工作

2、同步和非同步概念:

同步:前面的先執行,後面的再執行

非同步:不等前面迴圈的結果,後面也開始執行了。

//定義委託 public delegate void GetMethod(string name);//定義方法private void DoSomething(string name)        {            Console.WriteLine("*********************DoSomething******Start*************{0}*",Thread.CurrentThread.ManagedThreadId);            for (int i = 0; i < 1000000000; i++)            {                i++;            }            Console.WriteLine("*********************DoSomething******End**************{0}*",Thread.CurrentThread.ManagedThreadId);        }//調用:同步: GetMethod getMethod = DoSomething;  getMethod.Invoke("同步1");  getMethod.Invoke("同步2");//調用:非同步getMethod.BeginInvoke("非同步1",null,null);getMethod.BeginInvoke("非同步2",null,null); 
(1) 的結果,會看到同步1,同步2都是前面執行完後才執行的。異1步和非同步2是交叉進行的。

(1)

 

c# 進程(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.