I have a method which gets executed on another thread then the main thread. If it finishes, it calls a callback. But the main thread has to wait, otherwise it destroys the object where the callback wants to return.
Now, for simplicity, I have the following code:
int main()
{
Something* s = new Something();
s.DoStuff(); // Executed on another thread
delete (s); // Has to wait for DoStuffCallback() to be executed
}
void Something::DoStuff()
{
// Does stuff
// If done, calls its callback
}
void Something::DoStuffCallback()
{
// DoStuff has finished work
}
How can I wait until DoStuffCallback() got executed and then continue with the main thread?
Thanks a lot!
Edit:
This does not work for me, since I have not access to the right compiler. (I have as mentioned VS2010)