ThreadStart委託型別

2021-09-23 10:19:00 字數 1214 閱讀 3002

1.建立threadstart委託型別物件

namespace test

console.writeline(thread.currentthread.name + " has finished");

}static void main(string args)

else

}console.read();}}

}2.thread類有4個過載:

//// 摘要:

//     初始化 system.threading.thread 類的新例項。

//// 引數:

//   start:

//     system.threading.threadstart 委託,它表示此執行緒開始執行時要呼叫的方法。

//// 異常:

//   t:system.argumentnullexception:

//     start 引數為 null。

[securitysafecritical]

public thread(threadstart start);

//// 摘要:

//     初始化 system.threading.thread 類的新例項,指定執行緒的最大堆疊大小。

//// 引數:

//   start:

//     system.threading.threadstart 委託,它表示此執行緒開始執行時要呼叫的方法。

////   maxstacksize:

//     執行緒要使用的最大堆疊大小(以位元組為單位);如果為 0 則使用可執行檔案的檔案頭中指定的預設最大堆疊大小。重要地,對於部分受信任的**,如果 maxstacksize

//     大於預設堆疊大小,則將其忽略。不引發異常。

//// 異常:

//   t:system.argumentnullexception:

//     start 為 null。

////   t:system.argumentoutofrangeexception:

//     maxstacksize 小於零。

[securitysafecritical]

public thread(threadstart start, int maxstacksize);

C 委託二 委託型別

我們都應該清楚,在使用委託之前,先要定義乙個委託型別,如下所示 delegate int mydelegate int a,int b mydelegate md null 既然叫做委託型別 就說明 mydelegate 實際上是乙個類,上面的寫法只是一種簡單的縮略寫法,實際上,我們自己定義的委託,...

C 委託型別

委託是c 語言提供的新的引用型別,即委託型別,也稱 型別。在功能上類似於 c語言的函式指標,目的是通過委託型別物件去呼叫相同簽名的函式。委託是從system.delegate 中派生的,因此是型別安全的。採用委託可以實現通用程式的編寫。委託的操作步驟 1.定義委託型別 2.定義委託物件 3.定義委託...

C 函式委託型別

rel file list href file c 5cdocume 7e1 5cadmini 7e1 5clocals 7e1 5ctemp 5cmsohtml1 5c04 5cclip filelist.xml c 函式委託型別 rel file list href file c 5cdocum...