vb.net 多线程卡死界面,新手求前辈们帮助,感谢 10
Privatet40AsNewThread(NewThreadStart(AddressOfds40))'启动PrivateSubbtnRun_Click(senderA...
Private t40 As New Thread(New ThreadStart(AddressOf ds40))
'启动
Private Sub btnRun_Click(sender As System.Object, e As System.EventArgs) Handles btnRun.Click
t40.Start()
End Sub
Sub ds40()
If Run = False Then
Thread.Sleep(System.Threading.Timeout.Infinite)
End If
Dim i As Long = 0
Do Until Monitor = False
BeginInvoke(New EventHandler(AddressOf ds41), i)
i += 1
Thread.Sleep(30)
Application.DoEvents()
Loop
End Sub
Sub ds41(ByVal sender As System.Object, ByVal e As System.EventArgs)
For i As Integer = 0 To Number - 1 Step 1
iData = Me.libSource.Items.Item(i)
Me.libSource.SelectedIndex = i
'返回以空格隔断的字符
Dim data() As String = iData.Split()
Dim Carid As UShort = 0
'选择发送函数
Select Case data(0)
Case "Line"
iChiG.ModuleCard.d2410_set_vector_profile(data(9), data(11), 0.1, 0.1)
iChiG.ModuleCard.d2410_t_line4(Carid, data(3), data(5), data(7), 1000, 1)
Do
Thread.Sleep(100)
Loop While ah = 1
Case "Wait"
Case "Set"
iChiG.ModuleCard.d2410_write_outbit(Carid, data(2), data(5))
Case "Time"
Thread.Sleep(data(3))
End Select
Next
End Sub 展开
'启动
Private Sub btnRun_Click(sender As System.Object, e As System.EventArgs) Handles btnRun.Click
t40.Start()
End Sub
Sub ds40()
If Run = False Then
Thread.Sleep(System.Threading.Timeout.Infinite)
End If
Dim i As Long = 0
Do Until Monitor = False
BeginInvoke(New EventHandler(AddressOf ds41), i)
i += 1
Thread.Sleep(30)
Application.DoEvents()
Loop
End Sub
Sub ds41(ByVal sender As System.Object, ByVal e As System.EventArgs)
For i As Integer = 0 To Number - 1 Step 1
iData = Me.libSource.Items.Item(i)
Me.libSource.SelectedIndex = i
'返回以空格隔断的字符
Dim data() As String = iData.Split()
Dim Carid As UShort = 0
'选择发送函数
Select Case data(0)
Case "Line"
iChiG.ModuleCard.d2410_set_vector_profile(data(9), data(11), 0.1, 0.1)
iChiG.ModuleCard.d2410_t_line4(Carid, data(3), data(5), data(7), 1000, 1)
Do
Thread.Sleep(100)
Loop While ah = 1
Case "Wait"
Case "Set"
iChiG.ModuleCard.d2410_write_outbit(Carid, data(2), data(5))
Case "Time"
Thread.Sleep(data(3))
End Select
Next
End Sub 展开
2017-09-12
展开全部
“卡死”是一个非常主观的描述,如果你要让主线程杀掉卡死的线程,那么你必须给“卡死”做出准确的定义。什么是卡死?30秒没有响应就是卡死?那么“没有响应”的定义又是什么?你给出这些条件以后,杀掉一个线程就不难。Abort方法,Dispose方法,都可以。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询