CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 31 of 31
  1. #31
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,241

    Re: MFC: PostMessage and Handling it without the hassle (and a question).

    Quote Originally Posted by OReubens View Post
    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Page 3 of 3 FirstFirst 123

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
  •  





Click Here to Expand Forum to Full Width

Featured