c++ - Sequencing code in a multithreaded environment -


I have a multi-C ++ MFC application. To execute my program logic I have a worker thread, and the main thread is dedicated to managing GUI events. The GUI thread program spawns logic threads, and detaches execution from it, like this -

  Zero CMyDocument :: InGUIThread () {std :: Thread tProgramLogic (programLogicThreadFunction); TProgramLogic.detach ()}  

It takes approximately 5 minutes to execute my program logic.

Here's my problem: After the end of my program logic execution, I want to call the function in the main GUI thread. How can I signal my main thread to a programmable thread because it is near the end of execution?

Because PS is different because I separate my programLogic thread that I do not freeze my main thread, and thus it is responsive to GUI events.

After

you can go for a C ++ 11 async solution and With the results poll, but in my specific case (in a Windows environment) I want to go for an even better solution:

1) Define and deal with this map, such as

  #define WM_MYMSG (WM_USER + 42) BEGIN_MESSAGE_MAP (CMyApp, CWinApp) ON_MESSAGE (WM_MYMSG, ThreadHasFinished) END_MESSAGE_MAP ()  

2) P> Ends on main window

3) End of logic Handle ThreadHasFinished


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -