Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Mac Silverlight Resources for LocalMessageReceiver

I have an application written in Silverlight that is used on both Mac and Windows platforms. As part of its functionality, it must only be allowed to run one. We have implemented this using the LocalMessageReceiver approach and it works as expected.

However, we have an issue on the Mac. If the application crashes or is Force Quit, it is impossible to restart the application as the single instance code reports that the application is already running. The only recourse we have found so far is to restart the computer. However, this is inconvenient at best.

Is there a way on Mac OS X to clear the resources used by the LocalMessageReceiver without having to restart the computer? I assume that there are shared resources somewhere in the system, but I haven't found any documentation discussing what those resources are or how to reset them.

like image 722
John Haager Avatar asked Dec 01 '25 12:12

John Haager


1 Answers

Well... as no one else replied... this is my workaround; I cannot explicitly set the code, but I can get you the idea:

If you cannot listen on the LocalMessageReceiver() it can be for two reason

  1. because there is a real other silverlight instance running
  2. because there was a crash and the resource was not cleared properly

the trick to differentiate the reasons is to try to communicate to the LocalMessageReceiver. Set up a LocalmessageSender, add one handle to the response and try to send a message.

The "real" other silverlight instance would reply. The crash leftover no. So you can wait for a reasonable timeout for a reply.

If there is none (so it's the crash) you have some strategy: for example you can set up a new LocalMessageReceiver (with a "fallback" name) to check for other instances or something like that.

like image 112
Vito De Tullio Avatar answered Dec 03 '25 02:12

Vito De Tullio