Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MoveWindow deadlock?

I have a window on thread A, which at some point (as a result of a message being received on its wndproc) triggers an action on thread B, and then waits for the action to complete (using some sort of sync mechanism). Thread B then calls MoveWindow(), to move a child window within thread A's window (a standard textbox, for example). At this point the program goes into a state of deadlock for some reason. If MoveWindow() is being called from thread A, everything works. Any ideas why?


2 Answers

You could use SetWindowPos with the flag SWP_ASYNCWINDOWPOS, instead of MoveWindow.

The reason may be that ThreadA waits for ThreadB to handle some event but meanwhile ThreadB wait for ThreadA (the thread owning the window) to return the result of MoveWindow.

like image 167
jturcotte Avatar answered Dec 31 '25 03:12

jturcotte


What is the "some sort of sync mechanism"? If it is WaitFor(Multiple)Object(s), you can use [MsgWaitForMultipleObjects](http://msdn.microsoft.com/en-us/library/ms684242(VS.85).aspx)(Ex instead to wake up when you have a message and dispatch it as Lucero suggests.

like image 27
Logan Capaldo Avatar answered Dec 31 '25 02:12

Logan Capaldo