Re: MFC: PostMessage and Handling it without the hassle (and a question).
Quote:
Originally Posted by
OReubens
Well, you would really want to NOT put the invoke of the lamba inside the CS lock.
For one it might cause a deadlock (and it certainly will if the lambda again posts more lambdas) [...]
A programmer must never say "certainly" before testing.
Try this...
Code:
theApp.PostLambda([=]()
{
AfxMessageBox(_T("There was an old man of Five Rocks"));
theApp.PostLambda([=]()
{
AfxMessageBox(_T("Who shut his wife up in a box."));
theApp.PostLambda([=]()
{
AfxMessageBox(_T("When she said \"Let me out!\""));
theApp.PostLambda([=]()
{
AfxMessageBox(_T("He replied \"With no doubt"));
theApp.PostLambda([=]()
{
AfxMessageBox(_T("You will spend all your life in that box.\""));
});
});
});
});
});
...and see that no deadlock occurs.
But of course, me either don't say "certainly" in a gazillion of other possible cases. :)