The measure that DOTNET incident handles and implementation
The first pace: Define an appropriate commission
Exemple:
Delegate Void MoveEventHandler(Object Sender, moveEventArgs E)
Attention: The standard precatory in DotNet frame defines as follows:
Public Delegate Void EventHabdler(Object Sender, eventArgs E)
Parameter explains:
(1) Sender: Xing brings up sword of head of ⑺ of ⒌ Mu
(2) EventArgs: Acquiescent message is handled kind (do not contain additional data)
(3) the commission that suggests strongly to use a level defines incident
The 2nd pace: Define a right word
The EventArgs as a result of the standard kind do not include additional data, can accede this kind, make this kinds contain the information related to specific time,
Be like: Public Class MoveEventArgs
{ Public Int NewPosition;
Public MoveEventArgs(int NewPosition)
{
This.newPosition = NewPosition
}
}
The 3rd pace: Send square statement episode and install the code that arouses incident
Statement incident: Public Event entrusts type and incident label
Must use Public statement incident, receive debit to cannot register incident processor otherwise, the code that arouses an incident is as follows:
If (incident marks! = Null)
{
MoveEventArgs Args = New MoveEventArgs(value1);
}
Incident marks (This, args) (attention: Second incident is Dotnet touchstone event)
Additional: Suggest system of direct use standard entrusts EventHandler
Send message MyEvent(this.args);
Public Event EventHandler MyEvent;
State an incident is variable
Sender S1 = New Sender(); states one sends square example
S1. Incident marks the commission that = New defines (the functional code that wants implementation)
incident and the functional couple that want implementation.
Previous12 Next