|
|
|
start date: Thu, 16 Aug 2007 11:13:48 -0700,
posted on: microsoft.public.dotnet.distributed_apps
back
| Thread Index |
|
1
unknown
|
|
2
AlexS LEASE
|
VB .NET Form, Call Thread with Arguments and Invoke
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.
Date:Thu, 16 Aug 2007 11:13:48 -0700
Author:
|
Re: VB .NET Form, Call Thread with Arguments and Invoke
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.
wrote in message
news:1187288028.591581.219470@19g2000hsx.googlegroups.com...
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 AadirTextoChatCallBack(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.AadirTextoChat(Texto)
End Sub
Private Sub AadirTextoChat(ByVal Texto As String)
If Me.TBSalidaChat.InvokeRequired Then
Dim d As New AadirTextoChatCallBack(AddressOf
AadirTextoChat)
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.
Date:Thu, 16 Aug 2007 17:58:16 -0400
Author:
|
|
|