Hello,
"Frank D" <no****@nospam.com> schrieb:
I have a slight problem with writing the if statement of
the event
Here is a C# example
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
{
//Invokes the delegates.
Click(this, e);
}
}
}
The sample below will show you how to get the number of handles registered
for a specific event:
\\\
Public Class Main
Public Shared Sub Main()
Dim c As New FooBar()
AddHandler c.Foo, AddressOf Goo
c.AddSampleHandler()
c.AddSampleHandler()
Console.WriteLine( _
"Anzahl der Handler für Foo: {0}", _
c.NumberOfFooHandlers _
)
RemoveHandler c.Foo, AddressOf Goo
Console.Read()
End Sub
Private Shared Sub Goo()
End Sub
End Class
Public Class FooBar
Public Event Foo()
Public ReadOnly Property NumberOfFooHandlers() As Integer
Get
Return FooEvent.GetInvocationList().Length
End Get
End Property
Public Sub AddSampleHandler()
AddHandler Foo, AddressOf Moo
End Sub
Private Sub Moo()
End Sub
End Class
///
HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet