Beispiel #1
0
        public static bool IamFirst(SingletonController.ReceiveDelegate r)
        {
            bool flag;

            if (!SingletonController.IamFirst())
            {
                flag = false;
            }
            else
            {
                SingletonController.Receiver = (SingletonController.ReceiveDelegate)Delegate.Combine(SingletonController.Receiver, r);
                flag = true;
            }
            return(flag);
        }
Beispiel #2
0
        public static bool IamFirst()
        {
            bool   flag;
            string codeBase = Assembly.GetExecutingAssembly().GetName(false).CodeBase;
            string str      = codeBase.Replace("\\", "_");

            SingletonController.m_Mutex = new Mutex(false, str);
            if (!SingletonController.m_Mutex.WaitOne(1, true))
            {
                SingletonController.m_Mutex.Close();
                SingletonController.m_Mutex = null;
                flag = false;
            }
            else
            {
                SingletonController.CreateInstanceChannel();
                flag = true;
            }
            return(flag);
        }
Beispiel #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (SingletonController.IamFirst(new SingletonController.ReceiveDelegate(Program.myReceive)))
            {
                try
                {
                    Program.pi = new ProcessIcon();
                    Program.pi.Display();
                    Application.Run();
                    Program.pi.HideIcon();
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    MessageBox.Show(string.Concat("Error while initiating HermesProcessAgent: ", exception.Message), "Error");
                }
            }
            SingletonController.Cleanup();

        }