| Visual Basic (Declaration) | |
|---|---|
Public Delegate Sub InvokeEventHandler( _ ByVal sender As Object, _ ByVal e As InvokeEventArgs _ ) | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As New InvokeEventHandler(AddressOf HandlerMethod) | |
| C# | |
|---|---|
public delegate void InvokeEventHandler( object sender, InvokeEventArgs e ) | |
| Managed Extensions for C++ | |
|---|---|
public: __gc __delegate void InvokeEventHandler( Object* sender, InvokeEventArgs* e ) | |
| C++/CLI | |
|---|---|
public delegate void InvokeEventHandler( Object^ sender, InvokeEventArgs^ e ) | |
Parameters
- sender
- The source of the event.
- e
- An InvokeEventArgs object that contains the event data.
The following example demonstrates how to assign an event handler to an event.
| Visual Basic | Copy Code |
|---|---|
' *** EndInvoke Event *** ' You can either use the AddHandler statement to associate an event with an event handler in your init code AddHandler Ftp1.EndInvoke, New Dart.PowerTCP.Ftp.InvokeEventHandler(AddressOf Ftp1_EndInvoke) ' Or you can use the Handles keyword to associate an event handler with an event Private Sub Ftp1_EndInvoke(ByVal sender As Object, ByVal e As Dart.PowerTCP.Ftp.InvokeEventArgs) Handles Ftp1.EndInvoke | |
| C# | Copy Code |
|---|---|
// EndInvoke event this.ftp1.EndInvoke += new Dart.PowerTCP.Ftp.InvokeEventHandler(this.ftp1_EndInvoke); | |
As Microsoft describes in their MSDN documentation, the event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:
- A class that holds the event data. This class must derive from the base class EventArgs.
- A delegate that points to a method that provides the response to the event.
For more information about event handler delegates, see the "Using Events In PowerTCP" topic.
Target Platforms: Microsoft .NET Framework 2.0