diff options
-rw-r--r-- | spedytor/Program.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/spedytor/Program.cs b/spedytor/Program.cs index aafc441..0cd978c 100644 --- a/spedytor/Program.cs +++ b/spedytor/Program.cs @@ -1,20 +1,34 @@ using System; using System.Collections.Generic; using System.Windows.Forms; +using System.Threading; namespace spedytor { static class Program { + static Mutex mutex = new Mutex(false, "Spedytor - emkael.info"); /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + if (!mutex.WaitOne(TimeSpan.FromSeconds(1), false)) + { + MessageBox.Show("Spedytor już działa! Może gdzieś w tle?", "Błąd!", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + finally + { + mutex.ReleaseMutex(); + } } } } |