WPF application which calls an API, which needs a message pump

做~自己de王妃 提交于 2019-12-11 07:56:40

问题


I have a WPF application that calls an API to operate a device (a scanner). This API is COM based, and internally has a hidden window that the scanner sends messsages too. The intent of the API is to turn those windows messages into COM events. The problem is that the WPF application doesn't have a message pump, and therefore none of the messages are being delivered to the hidden window. Therefore none of the events are fired and it looks like the scanner is not responding.

How should I create a message loop in the WPF application that will be able to dispatch messages to the invisible window?


回答1:


This method can start a message pump if you don't have one already: http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.run.aspx

Note that each thread owns a separate message pump, which pumps messages for all windows created by that thread. You need to find the thread that created the hidden window.



来源:https://stackoverflow.com/questions/3065533/wpf-application-which-calls-an-api-which-needs-a-message-pump

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!