[VB.NET2.0] lire avec Serialport
Bonjour,
j'essaye de lire des données avec le composant SerialPort mais ça bug : que dois-je faire ?
code pour lire :
Code:
1 2 3 4 5
| Sub SerialPort1DataReceived(sender As Object, e As System.IO.Ports.SerialDataReceivedEventArgs)
Dim MaChaine As String
MaChaine = Me.SerialPort1.ReadExisting
Me.TextBox2.Text = MaChaine
End Sub |
message d'erreur lors de l'execution du programe lorsqu'il reçoit une data
Citation:
Exception System.InvalidOperationException was thrown in debugee:
Cross-thread operation not valid: Control 'textBox2' accessed from a thread other than the thread it was created on.
get_Handle()
set_WindowText()
set_WindowText()
set_Text()
set_Text()
set_Text()
SerialPort1DataReceived() - C:\Documents and Settings\...\Mes documents\SharpDevelop Projects\Test Port Serie\MainForm.vb:22,3
CatchReceivedEvents()
CallReceiveEvents()
WaitCallback_Context()
runTryCode()
RunInternal()
Run()
PerformWaitCallback()