Click here to Skip to main content
15,902,299 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalsave bitmap into file Pin
Anonymous15-Nov-04 7:56
Anonymous15-Nov-04 7:56 
GeneralRe: save bitmap into file Pin
ThatsAlok15-Nov-04 23:24
ThatsAlok15-Nov-04 23:24 
Generalwrite function writing more than one byte Pin
dkel352115-Nov-04 7:27
dkel352115-Nov-04 7:27 
GeneralRe: write function writing more than one byte Pin
Joaquín M López Muñoz15-Nov-04 8:24
Joaquín M López Muñoz15-Nov-04 8:24 
GeneralRe: write function writing more than one byte Pin
dkel352116-Nov-04 6:01
dkel352116-Nov-04 6:01 
GeneralRe: write function writing more than one byte Pin
Joaquín M López Muñoz16-Nov-04 9:19
Joaquín M López Muñoz16-Nov-04 9:19 
GeneralSending email in MFC multi-Threading Pin
zhngmm15-Nov-04 6:56
zhngmm15-Nov-04 6:56 
General"Proper" way to do this kind of thread syncronisation. Pin
Jon Hulatt15-Nov-04 6:37
Jon Hulatt15-Nov-04 6:37 
Hi,

I've got a worked thread that wakes up every second and does some really quick processing. But, when certain events happen in the UI thread I need to gracefully close the worker thread.

I've got this working, but the way i'm doing it seems a bit rubbish. Is there a better way?

I created 2 events:- "eventThreadShouldStop" and "eventThreadHasStopped".

my thread loops with a while(WaitForSingleObject()) on the eventThreadShouldStop event. When that event is set, the thread finishes up tidily. After it's finished up, it sets the eventThreadhasStopped event, which signals back to my main thread the the worked thread has finished.

So, just to cleanly stop a thread, i've having to use 2 separate event objects.

Is there a better way of doing this? Surely it's a frequent thing to do- signal to a thread it should end, and wait for it to end?

Jon



using System.Beer;

GeneralRe: "Proper" way to do this kind of thread syncronisation. Pin
Antony M Kancidrowski15-Nov-04 6:56
Antony M Kancidrowski15-Nov-04 6:56 
GeneralRe: "Proper" way to do this kind of thread syncronisation. Pin
John M. Drescher15-Nov-04 9:45
John M. Drescher15-Nov-04 9:45 
GeneralRe: "Proper" way to do this kind of thread syncronisation. Pin
Blake Miller15-Nov-04 10:22
Blake Miller15-Nov-04 10:22 
GeneralRe: "Proper" way to do this kind of thread syncronisation. Pin
Jon Hulatt15-Nov-04 23:28
Jon Hulatt15-Nov-04 23:28 
GeneralRe: "Proper" way to do this kind of thread syncronisation. Pin
Blake Miller16-Nov-04 4:21
Blake Miller16-Nov-04 4:21 
GeneralRe: "Proper" way to do this kind of thread syncronisation. Pin
Jon Hulatt16-Nov-04 4:28
Jon Hulatt16-Nov-04 4:28 
Generaldisplaying images in a dialog box Pin
ashsri15-Nov-04 5:42
ashsri15-Nov-04 5:42 
GeneralRe: displaying images in a dialog box Pin
pubududilena15-Nov-04 6:25
pubududilena15-Nov-04 6:25 
GeneralWhy Visual C++ generates other function name, but I use extern "C" Pin
Gasanov Tagir15-Nov-04 4:41
Gasanov Tagir15-Nov-04 4:41 
GeneralRe: Why Visual C++ generates other function name, but I use extern "C" Pin
David Crow15-Nov-04 4:59
David Crow15-Nov-04 4:59 
GeneralRe: Why Visual C++ generates other function name, but I use extern "C" Pin
Blake Miller15-Nov-04 10:25
Blake Miller15-Nov-04 10:25 
GeneralRe: Why Visual C++ generates other function name, but I use extern "C" Pin
Gasanov Tagir15-Nov-04 22:49
Gasanov Tagir15-Nov-04 22:49 
QuestionDynamic menus and messages? Pin
One Stone15-Nov-04 4:40
One Stone15-Nov-04 4:40 
AnswerRe: Dynamic menus and messages? Pin
Antony M Kancidrowski15-Nov-04 6:43
Antony M Kancidrowski15-Nov-04 6:43 
GeneralWaiting On Mutes's Pin
sweep12315-Nov-04 4:30
sweep12315-Nov-04 4:30 
GeneralRe: Waiting On Mutes's Pin
Antony M Kancidrowski15-Nov-04 6:12
Antony M Kancidrowski15-Nov-04 6:12 
QuestionHow to get full path of exe file? Pin
pubududilena15-Nov-04 2:00
pubududilena15-Nov-04 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.