Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Event DataArrival(ByVal sender As Object, ByVal Data As String)
- Private Sub RaiseEventSafe( _
- ByVal ev As System.Delegate, _
- ByRef args() As Object)
- Dim bFired As Boolean
- If ev IsNot Nothing Then
- For Each singleCast As System.Delegate In _
- ev.GetInvocationList()
- bFired = False
- Try
- Dim syncInvoke As ISynchronizeInvoke = _
- CType(singleCast.Target, ISynchronizeInvoke)
- If syncInvoke IsNot Nothing _
- AndAlso syncInvoke.InvokeRequired Then
- bFired = True
- syncInvoke.Invoke(singleCast, args)
- Else
- bFired = True
- singleCast.DynamicInvoke(args)
- End If
- Catch ex As Exception
- If Not bFired Then singleCast.DynamicInvoke(args)
- End Try
- Next
- End If
- End Sub
- Private Sub ThrowDataArrival(ByVal sender As Object, ByVal Data As String)
- RaiseEventSafe(DataArrivalEvent, New Object() {sender, Data})
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement