开发者

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

EventHandler Invoking question


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜