多线程问题求教
vb.net 编写的mobile6.1的程序,在运用多线程时出现以下错误是什么原因?
代码如下:
Public Class Form1 Public Delegate Sub ChangeTextDelegate(ByVal tb As TextBox, ByVal Conetnt As String) Dim myThread As Threading.Thread Public Sub ChangeTextInvoke(ByVal tb As TextBox, ByVal Conetnt As String) tb.Text = Conetnt End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click myThread = New Threading.Thread(AddressOf celiang) myThread.Start() End Sub Private Sub celiang() pp = 0 Dim str2(5) As String Dim str(100) str = Split(xx4_str, vbCrLf) Dim i As Integer Dim str_xx() As String Dim c As Integer For c = 0 To zongcehui - 1 ReDim Preserve dushu(c) For i = 0 To m - 1 str_xx = Split(str(i), ",") Try cl4.Invoke(New ChangeTextDelegate(AddressOf ChangeTextInvoke), New Object() {cl4, c + 1}) Threading.Thread.Sleep(1000) '延时函数 cl5.Invoke(New ChangeTextDelegate(AddressOf ChangeTextInvoke), New Object() {cl5, "Ⅰ"}) Threading.Thread.Sleep(1000) '延时函数 cl7.Invoke(New ChangeTextDelegate(AddressOf ChangeTextInvoke), New Object() {cl7, str_xx(0).ToString}) Threading.Thread.Sleep(1000) '延时函数'以下略 nextnext End SubEnd Class
Try cl4.Invoke(New ChangeTextDelegate(AddressOf ChangeTextInvoke), New Object() {cl4, (c + 1).ToString()}) Threading.Thread.Sleep(1000) '延时函数 cl5.Invoke(New ChangeTextDelegate(AddressOf ChangeTextInvoke), New Object() {cl5, "Ⅰ"}) Threading.Thread.Sleep(1000) '延时函数 cl7.Invoke(New ChangeTextDelegate(AddressOf ChangeTextInvoke), New Object() {cl7, str_xx(0).ToString}) Threading.Thread.Sleep(1000) '延时函数'以下略 next