tags:

views:

29

answers:

2

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

alt text

+1  A: 

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.

Hans Passant
Hi Hans, I checked the documentation for any event handlers, nothing obvious. I've attached a pic of the available.
madlan
Make it New EventHandler(Of RasConnectionEventArgs)(AddressOf watcher_Connected)
Hans Passant
Ahh that works too, thanks Hans.
madlan
A: 

Missed the thread sync object: watcher.SynchronizingObject = Me

http://dotras.codeplex.com/Thread/View.aspx?ThreadId=232088

madlan