Hello,
I am trying to learn some WCF principles by following an example of a WCF application (from Sacha Barber).
Now I would like to convert the following function into VB.NET
private void BroadcastMessage(ChatEventArgs e)
{
ChatEventHandler temp = ChatEvent;
if (temp != null)
{
foreach (ChatEventHandler handler in temp.GetInvocationList())
{
handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null);
}
}
}
but I have some problems, because the following code is not accepted by the compiler
Private Sub BroadcastMessage(ByVal e As ChatEventArgs)
Dim handlers As EventHandler(Of ChatEventArgs) = ChatEvent
If handlers IsNot Nothing Then
For Each handler As EventHandler(Of ChatEventArgs) In handlers.GetInvocationList()
handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing)
Next
End If
End Sub
it says
Public Shared Event ChatEvent(sender As Object, e As ChatEventArgs)' is an event, and cannot be called directly
Coming to the point, is it then possible in VB.NET get the handlers linked to a certain event in some other way?