Author | Message | Time |
---|---|---|
Imperceptus | I was running into a cross-threading error. I had hoped that using delegates would solve the issue. but instead I have a different error now. [code] Public Sub AddChat(ByVal ParamArray obj() As Object) Dim callback As New AddChatCallback(AddressOf AddChatImpl) If Me.InvokeRequired Then Me.Invoke(callback, obj) Else callback(obj) End If End Sub[/code] Data is recieved in mysocket.vb class Event Is raised which is picked up by a form which is a child of an mdi form. that form calls addchat in my rtb class. I get a TargetParameterCountException when it gets to Me.Invoke in the If statement. Obj does have data. Any idea's? | March 5, 2008, 7:01 PM |
Imperceptus | I made the code changes [code] Public Sub AddChat(ByVal ParamArray obj() As Object) Dim callback As New AddChatCallback(AddressOf AddChatImpl) If Me.InvokeRequired Then Me.Invoke(callback, obj.syncroot) Else callback(obj) End If End Sub [/code] This seems to have fixed my problem. Any other comments would be appreciated. | March 5, 2008, 10:59 PM |
Myndfyr | Calling Invoke() on a ParamArray method is tricky. Using SyncRoot isn't really what you want to do -- it's not intended for use that way. Is AddChatImpl's parameter a ParamArray? You can just change it to a regular array. | March 6, 2008, 6:06 PM |