static void Main(string[] args) { var receiver = new Read(); var doSomeThing = new DoSomeThing(); var commandRead = new ConcreteCommand(receiver); var commandDoSomeThing = new ConcreteCommand(doSomeThing); var invoker = new Invoker(); invoker.SetCommand(commandRead); invoker.SetCommand(commandDoSomeThing); invoker.RemoveCommand(commandRead); invoker.Execute(); Console.ReadKey(); }
private void GetReslut(IAsyncResult ar) { bool flag = true; while (flag) { byte[] recBuf = new byte[1024]; //获取返回数据的长度 int length = clinet.Receive(recBuf); //获取监听到的数据 string reslut = Encoding.UTF8.GetString(recBuf, 0, length); if (reslut == "1") { //刷新表格数据 DoSomeThing?.Invoke(); } } }
public Op() { DoSomeThing doSomeThing = new DoSomeThing(() => { Console.WriteLine("Hello World"); }); SayEvent += doSomeThing; }