Stoping thread....
-
Hi All, I have made a worker thread in which i have defined a critical section using CCriticalSection class. I have started this worker thread inside a for loop. Now my problem is when i want to stop my thread before completing the for loop(ie i want that all the threads already running should stop as well as no new thread should start). I am not getting the way to do this. Can anybody help me in this. Thanks in advance.
-
Hi All, I have made a worker thread in which i have defined a critical section using CCriticalSection class. I have started this worker thread inside a for loop. Now my problem is when i want to stop my thread before completing the for loop(ie i want that all the threads already running should stop as well as no new thread should start). I am not getting the way to do this. Can anybody help me in this. Thanks in advance.
In general the way to do it is to use a flag to tell the thread to continue looping or not: the loop will check this flag and continue its work until it is set. Then, from your main thread, you can set this flag in order to stop the thread. But of course, this depends a lot of your current architecture.
Cédric Moonen Software developer
Charting control [v1.2] -
Hi All, I have made a worker thread in which i have defined a critical section using CCriticalSection class. I have started this worker thread inside a for loop. Now my problem is when i want to stop my thread before completing the for loop(ie i want that all the threads already running should stop as well as no new thread should start). I am not getting the way to do this. Can anybody help me in this. Thanks in advance.
Can you post the sample code snippet. Upto my understanding, set a flag before start the thread. Based on the flag start or stop your threads in the for loop.
Sreedhar DV [Real success is having courage to meet failure without being defeated.]
-
Hi All, I have made a worker thread in which i have defined a critical section using CCriticalSection class. I have started this worker thread inside a for loop. Now my problem is when i want to stop my thread before completing the for loop(ie i want that all the threads already running should stop as well as no new thread should start). I am not getting the way to do this. Can anybody help me in this. Thanks in advance.
See here for thread shutdown discussions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne