Public?Class?Form1
創(chuàng)新互聯(lián)建站專注于錯那企業(yè)網(wǎng)站建設,響應式網(wǎng)站設計,商城網(wǎng)站制作。錯那網(wǎng)站建設公司,為錯那等地區(qū)提供建站服務。全流程按需設計,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務
Public?Class?SquareClass?'把多線程調(diào)用的函數(shù)封裝到類中,通過類事件返回
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?'多線程返回值測試,當線程運行完成激發(fā)事件
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?'響應事件函數(shù)
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?循環(huán))
thr.Start("a")
End?Sub
Sub?循環(huán)(a()?As?String)
'這里隨你干什么循環(huán)也行
For?Each?i?As?String?In?a
MsgBox(i)
Next
End?Sub
看懂了吧 參數(shù)只能有一個 也可以不是數(shù)組,在a() As String的a后面去掉括號就行
報錯信息是什么?截圖一下。
---------補充----------------
你這報錯與線程應該關(guān)系不大吧,是調(diào)用COM不熟悉造成的,在項目屬性里面有些相關(guān)配置你研究研究。