PSVRFramework icon indicating copy to clipboard operation
PSVRFramework copied to clipboard

Singleton Implementation

Open wildwing1970 opened this issue 8 years ago • 2 comments

It is just a small issue, but you can start the application 2 times and then it does not work correctly anymore!

How about implementation of a Singleton, that checks if Prog is already started

something like that

static class Program { static Mutex mutex = new Mutex(true, "PSVRToolbox"); [STAThread] static void Main() { if(mutex.WaitOne(TimeSpan.Zero, true)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); mutex.ReleaseMutex(); } else { MessageBox.Show("only one instance at a time"); } } }

wildwing1970 avatar Jan 11 '17 08:01 wildwing1970

https://github.com/wildwing1970/PSVRFramework/commit/3cc8b5462160cc39e924069de3a8356e02796951

wildwing1970 avatar Jan 17 '17 19:01 wildwing1970

I will use the same mutex in my QT Project ...... so that the programs do not interfere, when running

wildwing1970 avatar Jan 17 '17 19:01 wildwing1970