The answer is yes. I ran into this a couple of weeks ago and was helped out
by one of the gurus:
1) In my assembly with the main application (the one being imported):
Public Interface IHandleFTPReader
Sub AddHandlers(ByVal cl As FTPFileReader.FTPReader)
Sub RemoveHandlers(ByVal cl As FTPFileReader.FTPReader)
End Interface
Private ReadOnly m_Handler As IHandleFTPReader
Public Delegate Sub MessageToFormEventHandler(ByVal sender As Object, ByVal
e As MessageToFormEventArgs)
Public Event Message As MessageToFormEventHandler
Protected Overridable Sub OnMessage(ByVal e As MessageToFormEventArgs)
RaiseEvent Message(Me, e)
End Sub
Public Sub New(ByVal handler As IHandleFTPReader)
''add the handlers
m_Handler = handler
m_Handler.AddHandlers(Me)
End Sub
1a) event args
Public Class MessageToFormEventArgs
Inherits EventArgs
Private ms_Message As String
Public Sub New(ByVal sMessage As String)
ms_Message = sMessage
End Sub
Public ReadOnly Property Message() As String
Get
Return ms_Message
End Get
End Property
End Class
1b) to raise the event:
dim evt as New MessageToFormEventArgs("ERROR: blah ...")
OnMessage(evt)
2) In the form application:
Implements IHandleFTPReader
Public Sub AddHandlers(ByVal cl As yourproject1.yourproject1class)
Implements IHandleFTPReader.AddHandlers
AddHandler cl.Message, AddressOf MessageReceivedFromClass
End Sub
Private Sub MessageReceived(ByVal sender As Object, ByVal e As
projectnamegoeshere.MessageToFormEventArgs)
''do whatever you want with the message ...
End Sub
Hope this helps,
Timbo
"Serge Calderara" <se*************@maillefer.net> wrote in message
news:03****************************@phx.gbl...
Dear all,
I have one assembly named UserInfo which contains a form1
and a class1
I have a main application wich refer to the UserInfo
library by using the import keyword or adding reference to
my project.
From my main application, I would like to be informed when
the Button_click event of my form1 in UserInfo library is
fire.
Is there a safe way to retrive that event inside my
application through an interface?
thanks fo your answer
regards
serge