Delegates and Events Handler, what is the defference???

  • Thread starter Thread starter al
  • Start date Start date
A

al

Greetings,

Can someone please tell me the what is the defference betweeen
delegates and events handler???


MTIA,
Grawsha
 
al said:
Greetings,

Can someone please tell me the what is the defference betweeen
delegates and events handler???

An event handler is a procedure that handles events. A delegate is an object
pointing to a procedure, and the procedure can be an event handler but it
does not have to be.
 
Can someone please tell me the what is the defference betweeen
delegates and events handler???

..NET application raise events. They can (and should) be handled by a special
set of subs, ie.

Private Sub cbMyCombo_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbServerType.SelectedIndexChanged

this sub handles SelectedIndexChanged event for ComboBox control

Delegates, on the other hand, are like C++ pointers to functions, but more
powerful. From VS.NET help:

"It is a reference type that refers to a Shared method of a type or to an
instance method of an object. The closest equivalent of a delegate in other
languages is a function pointer, but whereas a function pointer can only
reference Shared functions, a delegate can reference both Shared and
instance methods. In the latter case, the delegate stores not only a
reference to the method's entry point, but also a reference to the object
instance with which to invoke the method."

Events and delegates are closely associated in Visual Basic .NET. An event
is a message sent by an object announcing that something important has
happened. Events are implemented using delegates, a form of object-oriented
function pointer that allows a function to be invoked indirectly by way of a
reference to the function.

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation
 
Back
Top