EventHandler Invoking question
I'm trying to invoke the below but the EventHander is not compatible with the RasConnectionEventArgs from my calling event, how would I invoke SetOverlayIcon and my notification icon on the UI thread?
Public Sub watcher_Connected(ByVal sender As Object, ByVal e As RasConnectionEventArgs)
If InvokeRequired Then
BeginInvoke(New EventHandler(AddressOf OnRegChanged))
Else
TaskbarManager.Instance.SetOverlayIcon(My.Resources.LockIcon, "Connected")
Me.NotifyIcon.ShowBalloonTip(5000, "Connected", e.Connection.EntryName, ToolTipIcon.Info)
End Sub
Jeff Winn's response to your support request:
The RasConnectionWatcher class is multi-threaded, as such you just need to set the SynchronizingObject property on the component. If you have the component on a form, you can set it to the form instance. It will handle the thread synchronization for you automatically once it's been set.
Or do it similar to this:
If InvokeRequired Then
BeginInvoke(New EventHandler(Of RasConnectionEventArgs)(AddressOf watcher_Connected), sender, e)
Else
'' etc...
End If
I'm guessing at the delegate type name.
Missed the thread sync object: watcher.SynchronizingObject = Me
http://dotras.codeplex.com/Thread/View.aspx?ThreadId=232088
精彩评论