我在一个类里面定义了一个for worker线程的static函数,
我把类的指针传进去,然后在这个static函数里面调用类的成员函数,成员函数
里面用::sendmessage()发送一个消息给另外一个窗口,调试的时候发现,老是在
::sendmessage()的时候程序就死在那里了,哪位有经验的大哥指点一下小弟啊.
谢谢拉

解决方案 »

  1.   

    试过用postmessage是可以解决,但是不懂其中缘由啊,不知道为什么会死锁啊。
    还忘了说一点就是,在sendmessage的时候有另外一个线程(同一个static函数)通过该类的指针在等待同步信号,不知道会不会有影响啊。有哪位大哥来指点下吗?谢谢
      

  2.   

    使用SendMessage系统要等到消息在对列中被处理后才会返回,而PostMessage就是只添加到消息队列,马上就返回了。
      

  3.   

    from MSDN:
    If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set. For more information on nonqueued messages, see Nonqueued Messages.