Re: WaitForSingleObject() will not deadlock



You can't, it is impossible; it violates the fundamental design of a mutex!!!!

Note that if you block the GUI thread, it blocks the GUI thread, and you can never dismiss
the dialog!

You are creating a complex solution to a trivial problem! See my earlier answer!
joe

On Sat, 30 Jun 2007 00:31:03 -0700, Frank Cusack <fcusack@xxxxxxxxxxx> wrote:

Code like this

if (WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
AfxMessageBox("acquired", ID_OK);
if (WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
AfxMessageBox("acquired", ID_OK);

displays 2 alert boxes. How do I make this deadlock instead?

-frank
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Worker Thread and GUI Problem
    ... Do NOT do a WaitForSingleObject in your main GUI thread! ... Allocate your parameter block on the heap, and have the thread delete the parameter block ... Read my essays on threading on my MVP Tips site. ...
    (microsoft.public.vc.mfc)
  • Re: CAnimateCtrl
    ... I'd PostMessage to the main GUI thread and let it add elements. ... WORK in the main GUI thread, the message pump is dead, your animation won't run, and your ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: How to use IO Completion Port to exchange data between two threads
    ... See my MVP Tips site. ... retrieve it. ... In the case of the main GUI thread, ... Should I create a IO Completion Port in each thread and then Read and Write ...
    (microsoft.public.vc.mfc)
  • Re: Simple Thread
    ... you have to use PostMessage to post a user-defined message to the ... main GUI thread to request whatever update you are doing. ... worker threads on my MVP Tips site. ...
    (microsoft.public.vc.mfc)
  • Re: SqlDataAdapter, SqlConnection, SqlCommand - Thread Safety
    ... the data adapter's fill / update methods on the GUI thread. ... controls work - you can't modify them from non-GUI thread. ... Miha Markic [MVP C#, INETA Country Leader for Slovenia] ...
    (microsoft.public.dotnet.framework.adonet)