[转] 委托 订阅者模式
[转] 委托 订阅者模式
Connection.cs
public delegatevoid ShowDataHandle(byte[] buff);
public event ShowDataHandle ShowData;
//获取数据
void GetData()
{
ShowData(buff);//触发事件
}
UI.cs
Connection.ShowData+=new Connection.ShowDataHandle(tcpconn_ShowData);
void tcpconn_ShowData(byte[] buff)
{
//更新数据到UI
}