0

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.Threading.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.

Community
  • 1
  • 1
Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98

1 Answers1

1

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thanks, then it means I'm not crazy. I had a demo WPF app that was working, but it doesn't work in my real app. I thought there might be some aspect of WPF/Dispatcher interaction that I was missing, but it appears not. My problem must be somewhere else. – Grant Birchmeier Apr 08 '11 at 13:55