示例#1
0
        public override void EnsureSingleApplicationInstance()
        {
            try {
                IController controller = Registrar.GetControllerInstance();
                if (controller == null)
                {
                    // No IController found on the bus, so no other
                    // instance is running. Register self.
                    Log <SystemService> .Debug("No other application instance detected. Continue startup.");

                    Registrar.RegisterController(this);
                }
                else
                {
                    // Another IController was found, so summon it
                    // and exit.
                    Log <SystemService> .Debug("Existing application instance detected. Summon and bail.");

                    controller.Summon();
                    System.Environment.Exit(0);
                }
            } catch (Exception e) {
                Log <SystemService> .Error("Could not EnsureSingleApplicationInstance: {0}", e.Message);

                Log <SystemService> .Debug(e.StackTrace);
            }
        }