开发者

WPF application calls an API that needs a message pump; Dispather.Run() causes problems

I have a WPF app that uses a non-WPF vendor library. My app does not receive any events that the library fires. I've been told that this is because I need a message pump.

In another (very similar) question, the accepted answer suggested using System.Windows.Threadi开发者_如何学Cng.Dispatcher.Run().

When I add in that call, however, my window won't pop up-- the app is effectively backgrounded and I have to shut it down with Task Manager.

I'm really stumped here, and I'm not even sure how to investigate it. Any help would be greatly appreciated.


You already have one if you use WPF, there's no other way that it can get any Windows notifications. Every WPF app starts life with a call to Application.Run() on the main thread. It is usually well hidden, auto-generated in the bin\debug\app.g.cs source code file. Application.Run() in turn calls Dispatcher.Run()

Your vendor is correct, without a message loop many COM components go catatonic. But since you have one you need to look for the problem elsewhere. Don't use the component on threads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜