none
有没有精确的多线程传递参数办法 RRS feed

  • 问题

  • 网上找的 可是不精确
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Thread(10)
            Dim i As Integer
            Dim Tasks As New TasksClass()
            For i = 0 To 10
                Thread(i) = New System.Threading.Thread(AddressOf Tasks.SomeTask)
                Tasks.StrArg = "某个参数" & i
                Thread(i).Name = "a" & i
                Thread(i).Start()
            Next
        End Sub
    
    Class TasksClass
        Friend StrArg As String
        Friend RetVal As Boolean
        Sub SomeTask()
            '   将   StrArg   字段用作参数。   
            MsgBox("StrArg   包含字符串" & StrArg)
            RetVal = True   '   设置返回参数的返回值。   
        End Sub
    End Class
    2009年4月4日 4:45

答案

全部回复