Is there a way to know in VB.NET if a handler has been registered for an event?

Posted by Seth Spearman on Stack Overflow See other posts from Stack Overflow or by Seth Spearman
Published on 2010-06-01T19:15:07Z Indexed on 2010/06/01 19:23 UTC
Read the original article Hit count: 298

Filed under:
|
|
|
|

In C# I can test for this...

public event EventHandler Trigger;
protected void OnTrigger(EventArgs e)
{
    if (Trigger != null)
        Trigger(this, e);
}

Is there a way to do this in VB.NET? Test for null I mean?

MORE INFO

I forgot to mention. I have classes written in C# but I am writing my unit tests in VB.NET.

I am trying this in the unit test...

If myObject.Trigger IsNot Nothing Then  
    'do something
End If

This is causing a compile time error which says ... "Public Event Trigger is an Event and cannot be called directly. Use the RaiseEvent statement to raise an event."

Seth

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET