|
-
March 20th, 2015, 10:30 AM
#31
Re: MFC: PostMessage and Handling it without the hassle (and a question).
 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.
Last edited by ovidiucucu; March 20th, 2015 at 01:21 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|