예제 #1
0
        public static void Main(string[] args)
        {
            MosaicApp.window = new MosaicWindow();

            SingletonController.Receiver += new SingletonController.ReceiveDelegate(MosaicApp.GetPassedArgs);

/*  disabled the singleton control
 *          // test if this is the first instance and register receiver, if so.
 *          if (SingletonController.IamFirst())
 *          {
 */
            if (args.Length > 0)
            {
                MosaicApp.window.SetStartupFiles(args);
            }

            Application.Run(window);

/*
 *          }
 *          else
 *          {
 *              // send command line args to running app, then terminate
 *              SingletonController.Send(args);
 *          }
 */

            SingletonController.Cleanup();
        }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
예제 #3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #4
0
 private void Awake()
 {
     if (instance != null)
     {
         Debug.Log("Destroy SingeltonController " + gameObject.name);
         Destroy(gameObject);
     }
     else
     {
         Debug.Log("Assign this instance SingeltonController " + gameObject.name);
         instance = this;
     }
 }
예제 #5
0
        static void Main(string[] args)
        {
            ObjectBase.Container = MEFLoader.Initialize();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            MainForm       form       = new MainForm();
            MainController controller = new MainController(form);

            using (SingletonController singletonController = new SingletonController("TVShowRename", form))
            {
                if (singletonController.IsFirstInstance)
                {
                    Application.Run((MainForm)singletonController.Enforcer);
                }
                else
                {
                    singletonController.SendMessageToFirstInstance(args);
                }
            }
        }
예제 #6
0
파일: Program.cs 프로젝트: Eisai/pragmasql
        static void Main(string[] args)
        {
            ConfigHelper.LoadFromDefault();
            bool singleInstanceOn = true;

            if (ConfigHelper.Current != null && ConfigHelper.Current.GeneralOptions != null)
            {
                singleInstanceOn = ConfigHelper.Current.GeneralOptions.IsSingleInstance;
            }

            if (!singleInstanceOn || SingletonController.IamFirst(new SingletonController.ReceiveDelegate(OnSingletonControllerReceive)))
            {
                if (User32.FindWindow(null, "PragmaSQL") != IntPtr.Zero)
                {
                    if (SendJumpListMsg(args))
                    {
                        return;
                    }
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadException += new ThreadExceptionEventHandler(Program.OnThreadException);
                splashScreen = new frmSplashScreen();
                splashScreen.Show();

                try
                {
                    ICSharpCoreWrapper.StartCoreServices();
                }
                catch (Exception ex)
                {
                    frmSplashScreen.HideSplash();
                    GenericErrorDialog.ShowError("PragmaSQL Error", "Fatal Error : Core services can not be started.", ex);
                    return;
                }

                AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(splashScreen.ShowAssemblies);
                HostServices hostSvc = new HostServices();
#if PERSONAL_EDITION
                hostSvc.HostEdition = HostEditionType.Personal;
#endif
                HostServicesSingleton.HostServices = hostSvc;


                _mainForm = new frmMain();

                if (args != null && args.Length > 0)
                {
                    FileInfo fi = new FileInfo(args[0]);
                    if (fi.Exists)
                    {
                        if (fi.Extension.ToLowerInvariant() == ".sqlprj")
                        {
                            _mainForm.CommandLineProjectFileName = args[0];
                        }
                        else
                        {
                            _mainForm.CommandLineScriptFileName = args[0];
                        }
                    }
                }
                else
                {
                    SendJumpListMsg(args);
                }
                Application.Run(_mainForm);
            }
            else
            {
                // send command line args to running app, then terminate
                SingletonController.Send(args);
                SingletonController.Cleanup();
            }
        }