出於某種原因,我的應用程序中的後臺線程無法更改我的主窗體上的任何標籤,文本框值等。沒有編譯錯誤,當線程執行任何事情時都不會發生。vb.net - 後臺線程問題
下面是一些示例代碼:
Imports System.Threading
Public Class Class1
Dim tmpThread As System.Threading.Thread
Private Sub bgFindThread()
Form1.lblStatus.Text = "test"
End Sub
Public Sub ThreadAction(ByVal Action As String)
If Action = "Start" Then
tmpThread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf bgFindThread))
tmpThread.Start()
ElseIf Action = "Abort" Then
If tmpThread.IsAlive = True Then tmpThread.Abort()
End If
End Sub
End Class
有人可以讓我知道我做錯了嗎?
的execption僅拋出。將CheckForIllegalCrossThreadCalls設置爲false是邪惡的! –
這個答案並沒有解決我的問題,但確實讓我走上了正軌。 – Joe