c ++/CLI线程无法连续运行 [英] c++/CLI threading not running continuously

查看:81
本文介绍了c ++/CLI线程无法连续运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试在我的c ++/CLI项目中进行线程化.
我没有很多经验:(

我有命令:

Hi
I am trying to do threading in my c++/CLI project.
I don''t have a lot of experience in it :(

I have the command:

SnifThread = gcnew Thread(gcnew ThreadStart(this,&test4::Form1::snif_data));


然后

SnifThread -> Start();



该线程运行一次,完成后停止运行.

为什么会这样?
如何保持线程前进?

谢谢

Emmos



The thread runs once and after it finished it stops going.

Why is that happening?
How can I keep my thread going?

Thanks

Emmos

推荐答案

在您的Form1::snif_data中放置一个while(running)循环,它将继续.

您可以通过将running设置为false来杀死线程.
Put a while(running) loop in your Form1::snif_data and it will continue.

You can kill the thread by setting running to false.


这篇关于c ++/CLI线程无法连续运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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