WaitForSingleObject & UI
Posted on 2009-05-02 11:32 S.l.e!ep.¢% 閱讀(2527) 評論(2) 編輯 收藏 引用 所屬分類: MulThreads在一個程序中,用了IOCP、多線程
在多線程程序中,需要同步,用了 WaitForSingleObject
在主線程使用 WaitForSingleObject 會有以下的問題
http://www.shnenglu.com/sleepwom/archive/2009/01/18/72268.html
http://www.shnenglu.com/sleepwom/archive/2008/12/18/69706.html
后來使用了 MsgWaitForMultipleObjects ?API
結果又產生了新的問題
http://www.shnenglu.com/sleepwom/archive/2009/04/22/80793.html
MsgWaitForMultipleObjects 一邊 wait for object 一邊處理消息
如果運氣差,處理了一個“阻塞”的消息,那么即使 object 被激活了,也不會返回
早上起床突然有了個新的想法
??
在UI不使用 WaitForSingleObject 之類的API,然后在本機創建一個服務,UI?層通過發送消息包去處理需要 Wait 的東西,然后在?Service 里使用 WaitForSingleObject
這樣一來,UI層就變得簡單多了,也可以避免因為使用WaitForSingleObject而出現界面死鎖的現象, 但 UI 和 service 之間多了一層協議?……
在多線程程序中,需要同步,用了 WaitForSingleObject
在主線程使用 WaitForSingleObject 會有以下的問題
http://www.shnenglu.com/sleepwom/archive/2009/01/18/72268.html
http://www.shnenglu.com/sleepwom/archive/2008/12/18/69706.html
后來使用了 MsgWaitForMultipleObjects ?API
結果又產生了新的問題
http://www.shnenglu.com/sleepwom/archive/2009/04/22/80793.html
MsgWaitForMultipleObjects 一邊 wait for object 一邊處理消息
如果運氣差,處理了一個“阻塞”的消息,那么即使 object 被激活了,也不會返回
早上起床突然有了個新的想法

在UI不使用 WaitForSingleObject 之類的API,然后在本機創建一個服務,UI?層通過發送消息包去處理需要 Wait 的東西,然后在?Service 里使用 WaitForSingleObject
這樣一來,UI層就變得簡單多了,也可以避免因為使用WaitForSingleObject而出現界面死鎖的現象, 但 UI 和 service 之間多了一層協議?……