1
//定义代理
2
public delegate void ConnectionErrorDelegate(ConnectionStatus status, string msg);
3
//定义代理事件
4
public event ConnectionErrorDelegate ConnectionErrorEvent;
5
//定义代理对象
6
private ConnectionErrorDelegate deleg = null;
7
//定义代理的方法
8
deleg = new ConnectionErrorDelegate(service_ConnectionErrorEvent);
9
//将代理对象赋值给service对象的代理事件
10
service.ConnectionErrorEvent += deleg;
11
//触发这个事件
12
ConnectionErrorEvent(status, errmsg);
先来分析一下,之前,我们常用了已经定好的代理和事件,我们要作的就是实例化代理对象,也就是真真要执行的方法,代理事件,和代理早就在.net组件中了,拿按钮的单击事件来说
2

3

4

5

6

7

8

9

10

11

12

我们在设计器中看到的是 this.button1.Click += new System.EventHandler(this.button1_Click);
其中的EventHandler









在单击按钮时,应该是产生了Click(boject,e.empter);的方法,这里面的参数是乱写的,大概就是表示鼠标的一些参数
具体思路就是这样,有什么不明白的可以加我的群聊