RSS
热门关键字:
当前位置 :| 主页>net development>

The measure that.NET incident handles

来源: 作者:Stand originally 时间:2008-12-21 Tag: 点击:

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

The 4th pace: Receive the square incident that registerProcessor

Incident processor also is one kind is entrusted, will receive debit to want to finishFunctionAdd incident processor, implementation entrusts the link up with with incident, after the message that once receive debit to receive,sends, will implement this method instantly, realize a function.

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.

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册