簡単な問題だと思います。シリアルポートからいくつかのデータを読み取り、ある解析ポイントで、いくつかのステータスラベルを更新する必要があります。驚いたことに、statuslabelはスレッドセーフです...私は知りませんでした...
わかりました。ただし、ステータスラベルには、スレッドセーフではないように見えるコンボテキストを含める必要があります。
statLabel1.Text = "Connected to"&cmbPort.text& "、found and happy"
そこで、任意のcomponent.textから「ReadSafe」機能を作成しようとしましたが、失敗しました...
Private Delegate Function ControlGetTextDelegate(ByRef cmp As Control) As String
Public Function ControlGetText(ByRef cmp As Control) As String
Dim s As String = ""
' control invoked from another thread ?
If cmp.InvokeRequired Then ' YES, so call through delegate
Dim dlg As New ControlGetTextDelegate(AddressOf ControlGetText)
cmp.BeginInvoke(dlg, {cmp})
Else ' NO, so call normally
s = cmp.Text
End If
Return s
End Function
誰かが少し助けを与えることができますか?