首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

多线程有关问题求教

2012-03-29 
多线程问题求教vb.net 编写的mobile6.1的程序,在运用多线程时出现以下错误是什么原因?代码如下:VB.NET cod

多线程问题求教
vb.net 编写的mobile6.1的程序,在运用多线程时出现以下错误是什么原因?

代码如下:

VB.NET code
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


[解决办法]
看提示是参数错误,试试
VB.NET code
                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 

热点排行