vbnet线程消息,vbnet线程同步
运行VS2013 的VB.NET程序时错误(其他信息: 线程正在运行或被终止;它无法重新启动。)怎么办?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
成都创新互联专注于播州企业网站建设,成都响应式网站建设,商城网站制作。播州网站建设公司,为播州等地区提供建站服务。全流程按需定制制作,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务
For s = 1 To 11 Step 10
t1 = New Threading.Thread(AddressOf setA)
t2 = New Threading.Thread(AddressOf setB)
t3 = New Threading.Thread(AddressOf setC)
t4 = New Threading.Thread(AddressOf setD)
t5 = New Threading.Thread(AddressOf setE)
t6 = New Threading.Thread(AddressOf setF)
t7 = New Threading.Thread(AddressOf setG)
t8 = New Threading.Thread(AddressOf setH)
t9 = New Threading.Thread(AddressOf setI)
t10 = New Threading.Thread(AddressOf setJ)
错误》》》 t1.Start()
t2.Start()
t3.Start()
t4.Start()
t5.Start()
t6.Start()
t7.Start()
t8.Start()
t9.Start()
t10.Start()
Next
同楼上,每个Thread只能运行一次
求大神指导VB.net 线程 ThreadState 的使用方法 怎么获取线程状态,是否被挂起堵塞停止等等
用time控件啊,获取threadstate后,按指定时间间隔规定向界面刷新,线程必须是全局变量
用一个有退出条件的无限循环的sub也行。
线程开始就触发该过程,用无限循环来刷新状态,线程完成即退出无限循环。局部变量的线程也可以用这种方式。
不过用法要正确,否则会出问题。
VB.NET 简单多线程
多线程一般是不推荐用的,因为线程之间如果有共享资源的话会引起竞争,需要加锁处理;而且线程间没有时序关系,所以你在调试中可能会出现异步处理结束顺序与开始处理顺序不一致的情况(我在调试中已经发现该问题)。
针对你提出的这个问题,采用了多线程处理,利用的是BackgroundWorker也就是异步处理控件进行了处理。
代码已经经过调试通过。欢迎交流,如有问题,留下QQ或其他联系方式。
代码如下,并附程序截图。
‘---------------------------------------------------
Imports System.ComponentModel '导入异步控件命名空间
Public Class Form1
Private howmany As Integer = 10
Private AnalysisNumber(0 To howmany - 1) As BackgroundWorker
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
creatNewBackgroundWorker()
addHandle()
startWork()
End Sub
Private Sub creatNewBackgroundWorker()
For i As Integer = 0 To AnalysisNumber.Length - 1
AnalysisNumber(i) = New BackgroundWorker
Next
End Sub
Private Sub addHandle()
For i As Integer = 0 To AnalysisNumber.Length - 1
AddHandler AnalysisNumber(i).DoWork, AddressOf AnalysisNumber_DoWork
AddHandler AnalysisNumber(i).RunWorkerCompleted, AddressOf AnalysisNumber_RunWorkerCompleted
Next
End Sub
Private Sub startWork()
For i As Integer = 0 To 9
Dim temp(0 To 9) As Integer
For j As Integer = 1 To 10
temp(j - 1) = 10 * i + j
Next
AnalysisNumber(i).RunWorkerAsync(temp)
Next
End Sub
Private Sub AnalysisNumber_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
Dim data As Integer()
data = CType(e.Argument, Integer())
Dim temp As Integer
For i As Integer = 0 To data.Length - 1
temp = data(i)
data(i) = temp * temp
Next
e.Result = data
End Sub
Private Sub AnalysisNumber_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
Dim data As Integer()
data = CType(e.Result, Integer())
For i As Integer = 0 To data.Length - 1
ListBox1.Items.Add(data(i))
Next
End Sub
End Class
各们,请教怎么使用vb.net编写两个进程间消息
两个方法
1.
要接收的窗口先使用FindWindow这个api获得句柄
调用SetForegroundWindow使其获得焦点并选中
调用.net方法:SendKeys.Send方法发送
2.使用API的SendInput
VB.net 如何设计多线程运行
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
分享标题:vbnet线程消息,vbnet线程同步
转载注明:http://pwwzsj.com/article/hsdhhp.html