Public Class Form1 Dim myThread As Threading.Thread Public Delegate Sub SetTextStringDelegate(ByVal tb As TextBox, ByVal str As String) Public Sub SetTextStringInvoke(ByVal tb As TextBox, ByVal str As String) tb.Text = str End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click myThread = New Threading.Thread(AddressOf SetTextString) myThread.Start() End Sub Private Sub SetTextString() TextBox1.Invoke(New SetTextStringDelegate(AddressOf SetTextStringInvoke), New Object() {TextBox1, "多线程访问界面"}) End Sub End Class
时间: 2024-10-07 03:40:54