I have been trying to nail this problem for a week now, but can't seem to get it right. I am building a Jabber application for the PocketPC and am using a third-party component for n-software. The n-software component does the usual things: expose a connect method, but also an OnSync event that fires when the device has logged into the Jabber server successfully. The OnSync THEN downloads the Jabber Roster (ala MyBuddies). Once I have these buddies, I want to parse them and put them, by group, into a TreeView. The issue is the old threading problem. I can't get the TreeView to load the Roster. ANy help would be appreciated... THANKS.
My code is as follows:
Delegate Sub MyEventHandler(ByVal sender As Object, ByVal e As nsoftware.IPWorks.XmppSyncEventArgs)
Private MyXmppSync As MyEventHandler
In the Private Sub Form1.Load I have:
New MyEventHandler(AddressOf Me.UpdateTVW)MyXmppSync =
-------------------------------------------------------------------------------------------------------------------
Private
Sub Xmpp1_OnSync(ByVal sender As Object, ByVal e As nsoftware.IPWorks.XmppSyncEventArgs) Handles Xmpp1.OnSyncNew Object() {sender, e}) 'Dim tvwsync As New EventHandler(AddressOf UpdateTVW) 'Me.BeginInvoke(tvwsync) End SubInvoke(MyXmppSync,
-------------------------------------------------------------------------------------------------------------------
Private
Sub UpdateTVW(ByVal sender As Object, ByVal e As nsoftware.IPWorks.XmppSyncEventArgs) tvwRoster.Nodes.Clear() Dim i As Integer For i = 1 To Xmpp1.BuddyCount Try If Xmpp1.BuddyGroup(i) <> "" ThenBuddyGroups.Add(Xmpp1.BuddyGroup(i), Xmpp1.BuddyGroup(i))
ElseBuddyGroups.Add(
"Other", Xmpp1.BuddyGroup(i)) End If Catch End Try Next 'Next, add all the groups and buddies to the tvwRoster: Dim group As DictionaryEntry For Each group In BuddyGroups 'create group node: Dim groupNode As TreeNode Dim GroupName As String = group.ValuegroupNode = tvwRoster.Nodes.Add(GroupName)
groupNode.ImageIndex = 3
'add buddies to the group For i = 1 To Xmpp1.BuddyCount If Xmpp1.BuddyGroup(i).Equals(group.Value) Then Dim id As String = Xmpp1.BuddyId(i)id = id.Split(
"@")(0) Dim newnode As TreeNode = New TreeNode(id)newnode.Tag = id
newnode.ImageIndex = 3
groupNode.Nodes.Add(newnode)
groupNode.ImageIndex = 3
'Dim newnode As TreeNode = New TreeNode(Xmpp1.BuddyId(i)) 'groupNode.Nodes.Add(newnode) End If Next Next End Sub
Help with Invoke on CF
WRBehning
Is this Compact Framework 1 or 2 In 1 you could only Invoke handlers that used EventHandler signature (object, EventArguments), so we had to pass any parameters via member variable.
What exactly is the error you are getting My guess it's NotSupportedException
WoFe
mary.oneill
Have you verified you hit this line assigning MyXmppSync in your OnLoad method (prior the the BP described above) What does the debugger tell you the value of MyXmppSync is after stepping over that line
stephane - Montpellier
Negative. It is locking up on the Invoke call when the XMPP component fires the OnSync event (which is not on the UI thread):
Private Sub Xmpp1_OnSync(ByVal sender As Object, ByVal e As nsoftware.IPWorks.XmppSyncEventArgs) Handles Xmpp1.OnSync
End Sub
As well, when I hover over specific variables, MyXmppSync comes up as "nothing" while "sender" and "e" have what I would expect. Many thanks. This one has me vexed.
Scott Simms