VB.net 如何设计多线程运行 200
PrivateFunctionMyFunctionHandler(byvalParamas()asstring)asBoolean//这里是正常的处理函数代码和功能//其...
Private Function MyFunctionHandler(byval Paramas() as string ) as Boolean
//这里是正常的处理函数代码和功能
//其中调用了第三方的插件dll
End Function
Private Function MyMulThreadCaller()
//多线程调用函数
MyFunctionHandler (GlobalParamas)
End Function
Sub Main()
Dim thr As New Thread(AddressOf MyMulThreadCaller)
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.Start() //启动多线程进程
Application .DoEvents
next
End Sub
===========
上述代码本来是想启用5个线程的,但是实际的运行中,只启用了2个线程,然后就卡死不动了!
请问,如何才能实现多线程呢? 展开
//这里是正常的处理函数代码和功能
//其中调用了第三方的插件dll
End Function
Private Function MyMulThreadCaller()
//多线程调用函数
MyFunctionHandler (GlobalParamas)
End Function
Sub Main()
Dim thr As New Thread(AddressOf MyMulThreadCaller)
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.Start() //启动多线程进程
Application .DoEvents
next
End Sub
===========
上述代码本来是想启用5个线程的,但是实际的运行中,只启用了2个线程,然后就卡死不动了!
请问,如何才能实现多线程呢? 展开
2个回答
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询