Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Singleton Implementation #48

Open
wildwing1970 opened this issue Jan 11, 2017 · 2 comments
Open

Singleton Implementation #48

wildwing1970 opened this issue Jan 11, 2017 · 2 comments

Comments

@wildwing1970
Copy link

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
Copy link
Author

wildwing1970@3cc8b54

@wildwing1970
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant