網頁

2015年11月25日 星期三

C# 簡單的 TCP Socket 測試

Last Update: 2016/04/24 02:46+08



Intro

兩種作法
System.Net.Sockets.TcpListener & System.Net.Sockets.TcpClient
System.Net.Sockets.Socket
但事實上差不多, 沒什麼特別需求可以用第一種節省點Code
Socket只能為 Actively 或 Passtively 不能同時為兩種
看倌們可以自己試試, 要求連線後成功後是不能等候連線的



2015年11月24日 星期二

C# Thread Monitor 鎖定作業

Last Update: 2015/11/24 18:55+08



Intro

C# 執行緒同步or鎖定作業的方式
System.Threading.Monitor
這邊稱為鎖定並不是keyword, 只是相較等候的方式, 這裡的行為比較像鎖定
另一種方法是等候作業 C# Thread 等候其它作業


C# Thread 等候其它作業

Last Update: 2015/11/24 18:55+08



Intro


C# 執行緒等候其它作業的方式
System.Threading.Thread.Join

System.Threading.EventWaitHandle extend System.Threading.WaitHandle
//不提, 被 AutoResetEvent 及 ManualResetEvent 實作

System.Threading.AutoResetEvent exnted System.Threading.EventWaitHandle

System.Threading.ManualResetEvent extend System.Threading.EventWaitHandle

System.Threading.CountdownEvent

以上介紹為等待作業的方式
另一種實作方法是鎖定作業 C# Thread Monitor 鎖定作業
也可用 delegate or event 來取代等候作業
依看倌們喜歡的設計方式