Vb.net中的线程问题 [英] Threading Problem in Vb.net

查看:177
本文介绍了Vb.net中的线程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了vb.net应用程序,并添加了一个Windows窗体,称为frmScan.
我放了两个文本框和两个标签.然后我写下面的
具有委托事件的线程.

Hi All,

I create vb.net application and i add one windows form,called frmScan.
i put two textboxes and two labels. Then i write the following
thread with delegate event.

Private Delegate Sub DoInitializedDelegate() 

Public motdet As New Thread(AddressOf MotionDetection)

Private Sub MotionDetection()
	''Do motion detection Work
	''It is never ending Loop until form unload.
End Sub



然后在表单加载事件中启动它.



Then I start it in my form load event.

Private Sub frmScan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	motdet.Start()   	
End Sub



因此,当我加载表格时,我的问题就开始了.
我可以看到表格,但是就像加载一些东西.
我以为我的运动检测线程永远不会终止循环,直到表单卸载.
我不能在上面提到的两个文本框中键入任何内容.
我应该怎么做 ?请帮助我.
谢谢

最佳rgds,
df



So my problem started when i load the form.
i can see the form but it is like loading something.
i thought my motion detecting thread is never ending loop until form unload.
i cannot type anything inside two text box i mentions in above.
how should i do ? pls help me.
thanks

best rgds,
df

推荐答案

向您永无止境的循环中添加Thread.Sleep(N),其中N是毫秒数,具体取决于您的要求(通常为1000表示1秒或1表示1毫秒).需要连续检查).
Add a Thread.Sleep(N) to your never ending loop where N is a number of milliseconds depending on your requirements (typically 1000 for 1 second or 1 for continuous checking required).


这篇关于Vb.net中的线程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆