Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, Preferences.APPLICATION_TITLE, out bool isFirstInstance))
            {
                if (isFirstInstance)
                {
                    NotificationIcon notificationIcon = new NotificationIcon();

                    Assembly     assembly = System.Reflection.Assembly.GetExecutingAssembly();
                    AssemblyName asmName  = assembly.GetName();
                    notificationIcon.notifyIcon.Text = string.Format("{0} {1}", Preferences.APPLICATION_TITLE, asmName.Version);

                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                    Application.Run();
                    notificationIcon.notifyIcon.Dispose();
                }
                else
                {
                    // The application is already running
                }
            }             // releases the Mutex
        }
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            bool isFirstInstance;
            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, Preferences.APPLICATION_TITLE, out isFirstInstance))
            {
                if (isFirstInstance)
                {
                    NotificationIcon notificationIcon = new NotificationIcon();

                    Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                    AssemblyName asmName = assembly.GetName();
                    notificationIcon.notifyIcon.Text  = String.Format("{0} {1}", Preferences.APPLICATION_TITLE, asmName.Version );

                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                    Application.Run();
                    notificationIcon.notifyIcon.Dispose();
                }
                else
                {
                    // The application is already running
                }
            } // releases the Mutex
        }