events in interfaces

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

If I have the interface like this

Interface IPluginAddin
Event Loaded()
Event UnLoaded()
End Interface

I have one class implementing the interface, which also will raise the
events... how in the world do i write an event handler in another class or
form for that event which is in the interface? thanks
 
something like this:

class MyClass
Implements IPluginAddin

Event MyEvent() Implements IPluginAddin.Loaded()
end class

As long as the signatures match, you should be good to go. Since you only
need to match the event signature, a single event can implement multiple
matching interface events which in your case would be something like:

class MyClass
Implements IPluginAddin

Event MyEvent() Implements IPluginAddin.Loaded(),
IPluginAddin.UnLoaded()
end class

If you use delegates, the delegate must be of the same type as the interface
event.

hope this helps..
Imran.
 
Brian,
how in the world do i write an event handler in another class or form for
that event which is in the interface?
You would write the event handler exactly the same way as you would if the
Event was in a Class!

You can use either WithEvents or AddHandler.

Public WithEvents plugin As IPluginAddin

Public Sub Main()
Dim plugin As IPluginAddin
AddHandler plugin.Loaded, AddressOf Plugin_Loaded
End Sub

Private Sub Plugin_Loaded()

End Sub

Private Sub plugin_UnLoaded() Handles plugin.UnLoaded

End Sub

Hope this helps
Jay
 

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

Back
Top