Raising an Event

  • Thread starter Nicholas Paldino [.NET/C# MVP]
  • 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.
 
C

Cooly Martziano

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How can these lines be rewritten 15
Delegates and Events 8
OnClick event name 6
struggling with events 4
Event Subscription. Why? 8
Handling a C# event from VB.NET 3
Raising and event 3
Delegates/events 8

Top