So I have a custom control that basically acts like a listview, but it draws everything out and finds where the mouse is and all that.
But when I have another class that goes in a chatroom and receives data, then raises an event to the parent (which is the main form), I then pass it through a delegate and then it adds to the custom control.
This seems to take a lot longer to add items to the list than If I just use Control.CheckForIllegalCrossThreadCalls = False and bypass the delegate?
What should I do.
Code:Private Sub ChatClient_UserListItem(ByVal Username As String, ByVal PrimaryIP As UInteger, ByVal PrimaryPort As UShort, ByVal Connection As UShort, ByVal Files As UInteger, ByVal Rank As Byte) Handles ChatClient.UserListItem If InvokeRequired = True Then Me.Invoke(New ChatClient_UserListItemSafe(AddressOf ChatClient_UserListItem), Username, PrimaryIP, PrimaryPort, Connection, Files, Rank) Else 'Control.CheckForIllegalCrossThreadCalls = False Call AddUser(Username, PrimaryIP, PrimaryPort, Connection, Files, Rank) End If End Sub
Is there a faster way to pass all the info, or should I just bypass the cross thread check and not use a delegate?




Reply With Quote