The Delegate Sub can be put anywhere within the Class declaration, but not within another Sub or Function.
The name of the EventHandler Function should replace
ThisFunction. In other words,
the name of the function that is being called when the Event is being raised.
The remainder of the code would go into the beginning of the EventHandler function like this:
Public Sub EventHandler()
'Test to see if the correct thread is being used. If not, InvokeRequired will be true.
If Me.lblFilename1.InvokeRequired Then
'If InvokeRequired = True then this function will be re-called from the UI Thread.
Dim d As New LengthyProcessCallback(AddressOf ThisFunction)
Me.Invoke(d)
Else
Place your code here from the EventHandler Function
End If
End Sub