Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using System.Threading;
- namespace GuiMutex
- {
- static class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- string MutexName = "MediatutorialMutex";
- using (Mutex MutexKu = new Mutex(false, @"Global\" + MutexName))
- {
- if (!MutexKu.WaitOne(0, false))
- {
- MessageBox.Show("Instance already running");
- return;
- }
- GC.Collect(); //Garbage Collector
- Application.Run(new Form1());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement