大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Public Class Form1
创新互联建站专注于错那企业网站建设,响应式网站设计,商城网站制作。错那网站建设公司,为错那等地区提供建站服务。全流程按需设计,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务
Public Class SquareClass '把多线程调用的函数封装到类中,通过类事件返回
Public Value As Double
Public Square As Double
Public Event ThreadComplete(ByVal Square As Double)
Public Sub CalcSquare()
Square = Value * Value
RaiseEvent ThreadComplete(Square)
End Sub
End Class
Dim WithEvents oSquare As SquareClass
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '多线程返回值测试,当线程运行完成激发事件
oSquare = New SquareClass()
Dim t As New Threading.Thread(AddressOf oSquare.CalcSquare)
oSquare.Value = 30
t.Start()
End Sub
Sub SquareEventHandler(ByVal Square As Double) Handles oSquare.ThreadComplete '响应事件函数
MsgBox("The square is " Square)
End Sub
End Class
Sub Main()
Dim thr As Thread
For Pi As Integer=0 To 4 //启用5线程
MulParams =Pi vbTab sFile vbTab dFile vbTab 1 vbTab DelN vbTab cr vbTab cg vbTab cb vbTab IndexI
GlobalParamas(pi)=MulParams .Split(vbTab)
thr=New Thread(AddressOf MyMulThreadCaller)
thr.Start() //启动多线程进程
Application.DoEvents
Next
End Sub
Sub Main()
Dim thr As New Thread(AddressOf 循环)
thr.Start("a")
End Sub
Sub 循环(a() As String)
'这里随你干什么循环也行
For Each i As String In a
MsgBox(i)
Next
End Sub
看懂了吧 参数只能有一个 也可以不是数组,在a() As String的a后面去掉括号就行
报错信息是什么?截图一下。
---------补充----------------
你这报错与线程应该关系不大吧,是调用COM不熟悉造成的,在项目属性里面有些相关配置你研究研究。