I am working on a multi-instance appalication there is application update function that downloads the update from internet and install it.
Now Problem is if there are multiple instances are open then thay all try to install update that leads to error.
Simple code Snippet I learnt after reading the tutorials.
static bool IsSingleInstance()
{
try
{
// Try to open existing mutex.
Mutex.OpenExisting("myMutex");
}
catch
{
// If exception occurred, there is no such mutex.
Window1.mutex = new Mutex(true, "myMutex");
// Only one instance.
return true;
}
// More than one instance.
return false;
}
I am new at C#. So can anybody tell me that how to use Mutex to ensure that only one instance can download and install update.
please tell the links for appropriate tutorials if you know on this topic.
make the mutex global by
Window1.mutex = new Mutex(true, "Global\\myMutex");Mutex.OpenExisting("Global\\myMutex");