Event-based programming is the cornerstone of .NET FRAMEWORK
The event mechanism in .NET Framework uses delegate (callback)
The event is a commonly used method to demonstrate the coupling between event source objects (objects of generating events) and event receiver objects (subjects to event notifications).
Entrusted 3 steps similar to the method of the method in the application pointing to the object: 1 Declaring the delegate type 2 Create a delegate object, and bind the object binding method 3 using the delegate object to call the method
.NET Framework supports two types of commissioned average delegation: allowing an object to call a method multicast delegation: allowing a series of methods to be called on different objects to maintain a call object
Use the multicast commissioned step: 1 Define a delegate type 2 to write the same signature method as a delegate 3 to create a delegate object, bind it to the first method 4 that needs to be called, create another delegate object, bind to the next A method of calling the method 5 System.deLegate class, combined into an integrated multicast commission
Asynchronous entrustment can call the entrusted instance in the background thread: 1 Synchronous call, wait for the waiting method, the most common 2 asynchronous call, wait for the method to execute, endInvoke (), but before the method is executed, call 3 asynchronous Call, register a callback method, once the execution is completed, give notifications
The implementation of the event uses the event handler method of the delegate storage subscription, a typical OBServer design mode implements each event, you must specify the following two content: event name, the signature of the event (parameter list)
SYSTEM.EVENTHANDLER A built-in commissioned event cannot have a return type, only from the event source object to the one-way information flow of the event recipient object
Static incidents are rare, relative to general events
Defining the way you register, you don't need to define customized registration methods in most cases, but this technology can make your code simpler and fast. In Framework, most controls use customized registration methods.
Base classes and subclasses cannot reference the same entrusted inheritance and polymorphisms support, polymorphisms are supported by inheritance, regarding a type of object as a polymorphism of another type of instance
The base class is defined as Virtual. The derived class can rewrite the operation mark as the non-virtual method. It cannot be rewritten. The operation declaration is Virtual, and the implementation can be rewritten to abstract, and the implementation must be rewritten.
The class inherits from the System.Object structure inherits from System.ValeType, inherits from System.Object to the interface type it implements it, carefully, causing any objects that the interface is not supported by the reference type.