i have a question on how to exchange information between my main thread and worker threads. I have a worker thread that writes data to file and i want it to inform my main thread via "Event" handle (old school win32 event) that something failed while writing. How can i achieve that?
I have a class "WriteContainer" in file "WriteContainer.h" and i declared
extern HANDLE g_Event in that header.
In my main.cpp i defined the HANLDE g_Event.
In the main function i Called "CreateEvent( ... )
hoping this leads to ONE handle that i can "signal" with "setEvent" function from all instances of my "WriteContainer" class in all the different threads.
This does not work, so i think i was wrong. Does anyone have any idea on this?
thanks for answering my question. I don't know why this does not work. I set the event in my parallel thread, but in my main thread, it won't be recognized by
"WaitForSingleObject" (although i am not 100% sure if this would be the right way to "listen" for that event)
I can try to rproduce my issue in a more simple example, but was not able to post code this morning, so i didn't yet try ...
OpenEvent might work. the thing is: the event handle itself is visible and accessable every where, so i think the "global variable" is not my issue ...