本文介绍了MoveWindow死锁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在线程A上有一个窗口,该窗口在某个时候(由于在其wndproc上收到消息)触发了对线程B的操作,然后等待该操作完成(使用某种同步机制) )。然后,线程B调用 MoveWindow(),以在线程A的窗口内移动一个子窗口(例如,标准文本框)。此时,由于某种原因,程序进入了死锁状态。如果从线程A调用 MoveWindow(),则一切正常。知道为什么吗?

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?

推荐答案

您可以使用带有标志SWP_ASYNCWINDOWPOS的SetWindowPos,而不是MoveWindow。

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

原因可能是ThreadA等待ThreadB处理某些事件,但同时ThreadB等待ThreadA(拥有窗口的线程)返回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.

这篇关于MoveWindow死锁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:13