Raising an Event

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

Cooly,

In order to do that, you would get a reference to the delegate list,
check for null, and then call. For example, say you had an event defined
like this:

public event EventHandler MyEvent;

In your code, you would do this:

// Assign MyEvent to a temp event handler.
EventHandler eventHandlers = MyEvent;

// Check for null.
if (eventHandlers != null)
// Fire the event.
eventHandlers(this, EventArgs.Empty);

Hope this helps.
 
Hi Guyz,

I wondered how in C# I could raise an spcific event.
For example, in VB.NET, when you would like to raise a specific event
you just write "RaiseEvent <event name>"

Any Ideas ?

Thanks,
Cooly M.
 
Back
Top