1 // Define proxy
2 Public Delegate Void Connectionerrordelegate (connectionstatus status, String MSG );
3 // Define proxy events
4 Public Event Connectionerrordelegate connectionerrorevent;
5 // Define proxy object
6 Private Connectionerrordelegate Deleg = Null ;
7 // Define proxy Methods
8 Deleg = New Connectionerrordelegate (service_connectionerrorevent );
9 // Proxy events that assign a proxy object to a service object
10 Service. connectionerrorevent + = Deleg;
11 // Trigger this event
12 Connectionerrorevent (status, errmsg );
First, let's take a look at the analysis. Previously, we often used established proxies and events. What we want to do is to instantiate the proxy object, that is, the methods that really need to be executed, proxy events, and proxy have long been in.. NET component. For the Click Event of the button
What we see in the designer is this. button1.click + = new system. eventhandler (this. button#click );
Among them, eventhandler // Abstract:
// Indicates the method to process events that do not contain event data.
[Serializable]
[Comvisible ( True )]
Public Delegate Void Eventhandler ( Object Sender, eventargs E );
While this. button1.click is
//
// Abstract:
// It occurs when you click the control.
Public Event Eventhandler click;
Now we understand that what we need to do is to define a method with the same parameters as the proxy. We can give the proxy method entry to the event and click the button.
When you click a button, the click (boject, E. empter); method should be generated. The parameters here are gibberish, which is probably the parameters of the mouse.
The specific idea is this. If you don't understand anything, you can add my group chat.