Re: VB .NET Form, Call Thread with Arguments and Invoke -
08-16-2007
, 05:58 PM
You created parameterized thread start when creating new Thread
(EscribirChat has parameter), but you call Thread.Start without parameters,
so compiler expects parameterless thread start object.
Try
Me.ThreadChat.Start(Datos)
Check ParameterizedThreadStart class and how to use it.
<javiercaos (AT) gmail (DOT) com> wrote
Hi,
I'm developing a Windows form application, with multithreading and my
problem is this:
When i receive any data begining by "1", i need to create a thread
calling the sub "EscribirChat" with one argument.
This is the code that i have now:
Delegate Sub AñadirTextoChatCallBack(ByVal Texto As String)
Private ThreadChat As Thread = Nothing
Private Sub DatosRecibidosServer(ByVal Datos As String)
Select Case Datos.Chars(0)
Case "0" : OperacionInterna(Datos)
Case "1"
Me.ThreadChat = New Thread(AddressOf
Me.EscribirChat)
Me.ThreadChat.Start()
End Select
End Sub
Private Sub EscribirChat(ByVal Texto As String)
Me.AñadirTextoChat(Texto)
End Sub
Private Sub AñadirTextoChat(ByVal Texto As String)
If Me.TBSalidaChat.InvokeRequired Then
Dim d As New AñadirTextoChatCallBack(AddressOf
AñadirTextoChat)
Me.Invoke(d, New Object() {Texto})
Else
OperacionChat(Texto)
End If
End Sub
Private Sub OperacionChat(ByVal Datos As String)
Dim Tam As Integer = Convert.ToInt16(Datos.Substring(2,
3))
Dim Cadena As String
Cadena = Datos.Substring(6, Tam)
Me.TBSalidaChat.Text = Me.TBSalidaChat.Text & "<" &
Me.NombreOponente & "> : " & Cadena & vbCrLf
Me.TBSalidaChat.Select(Me.TBSalidaChat.Text.Length , 0)
Me.TBSalidaChat.ScrollToCaret()
End Sub
And Microsoft Visual Studio 2003 tell me:
"Method 'Private Sub EscribirChat(ByVal Texto As String)' does not
have the same signature as delegate 'Delegate Sub ThreadStart()'"
Can someone help me for solve this problem?.
Thank you very much.
Javi. |