Give you one example.
Define an Interface in your solution:
Interface ICallback
Sub CallbackMethod(ByVal str As String)
End Interface
Define a class:
Friend Class Class1
Private icb As ICallback
Public Sub RegisterInterFaceForCallback(ByVal cb As ICallback)
'this method receives a reference to the client.
'Register the client for the callback
icb = cb
End Sub
Public Sub UnRegisterInterfaceForCallback()
'Unregister the client
icb = Nothing
End Sub
Public Sub UseInterfaceCallback()
'Make sure something is registered first
If Not icb Is Nothing Then
'Call back into the client code
icb.CallbackMethod("Item1")
End If
End Sub
End Class
The From you have. Implements the ICallBack Interface:
Public Class Form1
Inherits System.Windows.Forms.Form
Implements ICallback
Public Sub CallbackMethod(ByVal str As String) Implements
ICallback.CallbackMethod
'This method is called from Class1 after the form is registered
'with the instance.
ListBox1.Items.Add(str)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim refClass1 As New Class1
'Register the client, passing a reference to itself
refClass1.RegisterInterFaceForCallback(Me)
'Call the method which will in turn call back into
'the client
refClass1.UseInterfaceCallback()
'Unregister the client
refClass1.UnRegisterInterfaceForCallback()
End Sub
End Class
Hope this get you a better idea.
chanmm
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!