Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C++
SnifThread = gcnew Thread(gcnew ThreadStart(this,&test4::Form1::snif_data));

and then
C++
SnifThread -> Start();


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

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

Thanks

Emmos
Posted
Updated 26-Sep-11 19:24pm
v2
Comments
André Kraak 27-Sep-11 1:25am    
Please post the code for the test4::Form1::snif_data function.

If you wish to change your question use the Improve Question button.

1 solution

Put a while(running) loop in your Form1::snif_data and it will continue.

You can kill the thread by setting running to false.
 
Share this answer
 
Comments
Philippe Mori 27-Sep-11 19:38pm    
Effectively if yoy function must be executed multiple times, add a loop and an exit condition is the way to go.

Without details on your snif_data function, we cannot help you more than that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900