0

My MFC program remotes a WMP instance to catch WMP events and is using IWMPCore, IWMPCore3, IWMPPlaylistCollection, IWMPMediaCollection to interact with WMP using COM. The remote instance is working find and it is avle to catch the events, but when I started fetching all the details of all songs(almost 5100 songs), WMP stops responding until my application fetches all the songs and release all the above instance. Can anyone please help me out with the issue and how can it be fixed?

DTdev
  • 538
  • 1
  • 18
  • 32

1 Answers1

2

WMP ActiveX control is an STA COM object, so all interaction (method calls) goes through instantiation thread, which is in most cases the UI thread. That is, whatever you do with the interfaces, the calls block GUI for the time of the call.

You need to either pump window messages in the middle of your activity to unblock UI (show progress and let user hit Cancel button), or create a worker thread initialized as STA and obtain the collection details using a secondary invisible instance of WMP there.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Actually I just moved the WMP COM code to a thread other than main thread. This worked fine. :) – DTdev May 25 '15 at 12:00