How to prevent Windows Media Center from launching multiple copies of your application

I posted an item on the Media Center Sandbox site today that I wanted to link here as well in case anyone is interested.  Windows Media Center maintains separate process spaces for each application that is launched and stores up to 8 of them in a back-stack to allow users to navigate back to their previous experiences.  Because of this feature, it is possible to launch multiple instances of a Windows Media Center application.  This can lead to performance bottlenecks and resource contention issues.

Jossef Goldberg, a program manager on the Windows Presentation Foundation (WPF) team, recently published some sample code that demonstrates how to implement a solution that uses a mutex to prevent Windows Media Center from launching more than one instance of an application.

I encourage you to check out my Sandbox blog post for a more in-depth description of the algorithm to address this issue, and also to check out this post from Jossef for a link to download a sample XBAP solution that uses this algorithm.


Comments (3)

  1. jclark says:

    I understand how this works with MCML and XBAP managed code applications, the application being launched has to create the mutex so we can check for it when launching a second time. Is there any way to prevent launching multiple copies of an HTML application on Media Center?

  2. Hi JClark – I’m sorry, but I’m not aware of a way to do this for HTML applications.  You may want to also ask on in case someone there knows of a method of doing this that I don’t know about.

  3. jclark says:

    Thanks astebner. I dont know if this would help but I have something I have discovered in testing that may take this somewhere (or not). I have created an application with two entrypoints. The first is the standard "URL" entry to my HTML application. The second entrypoint is using an "ADDIN" to managed code. In the managed code "public void Launch" I have:


    If I launch the application with the first entrypoint using the URL my HTML application will launch. I can then use the second entrypoint to the ADDIN and it will return to my HTML application. This provided me with an idea that if the ReturnToApplication() could throw an exception if it did not have an application to return to then we could use a try…catch. We could try to ReturnToApplication(), if it is running it would return. If not we could catch the exception and launch the application. I’m reaching but thought it might trigger some thought.

Skip to main content