How to ensure that a Silverlight OOB application has only one instance?

Is there a way to guarantee that only one instance of the desktop version of the trusted Silverlight 4 Out Of Browser application will be launched?

Or do I need to manually force this by creating some kind of rude mutex?

If I have to do this on my own, I would look at creating a file in isolated storage as a lock, and then deleting it when I exit. I would check the existence of these files at startup to prevent the next instance from opening. Obviously, I need a way to deal with the crash of the application or to exit another way that prevents the removal of the lock file. My instinct was to have a timeout in the file and therefore ignore it if it is old for a certain period of time. Unfortunately, the application plays movies, so it is likely to work for several hours under normal circumstances. A lockout timeout of several hours is unlikely to be popular among users in this situation. Are there any better solutions?

+4
source share

All Articles