Example #1
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isFirstInstance;
            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, "SharpTouch", out isFirstInstance)) {
                if (isFirstInstance) {
                    SharpTouchApp app = new SharpTouchApp();
                    app.m_notifyIcon.Visible = true;
                    Application.Run();
                    app.m_notifyIcon.Dispose();
                } else {
                    // The application is already running
                    // TODO: Display message box or change focus to existing application instance
                }
            } // releases the Mutex
        }
Example #2
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isFirstInstance;

            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, "SharpTouch", out isFirstInstance)) {
                if (isFirstInstance)
                {
                    SharpTouchApp app = new SharpTouchApp();
                    app.m_notifyIcon.Visible = true;
                    Application.Run();
                    app.m_notifyIcon.Dispose();
                }
                else
                {
                    // The application is already running
                    // TODO: Display message box or change focus to existing application instance
                }
            } // releases the Mutex
        }