예제 #1
0
        public void Run(Form f = null)
        {
            Console.WriteLine("AppLoader.Run", "Bootstrapper enters IStarter.Run method.");
            if (this.StartShouldBeInterrupted())
            {
                return;
            }
            ForceEarlyCreationOfBroadcastEventWindow();
            Application.EnableVisualStyles();
            //this.CreateStartupPreloadedContext();

            m_ViewApplicationContext.GetRequiredDlc <IShortcutManager>("Siemens.Automation.FrameApplication.ShortcutManager");
            m_ViewApplicationContext.DlcManager.Load("Siemens.Automation.FrameApplication.Services.RegisterServices");
            m_ViewApplicationContext.SiblingInBusinessLogicContext.AutoLoadDlcs();
            m_ViewApplicationContext.AutoLoadDlcs();

            if (f == null)
            {
                CreateForm();
            }
            else
            {
                m_MainApplicationForm = f;
            }

            SynchronizationContext current = SynchronizationContext.Current;

            try
            {
                SynchronizationContext.SetSynchronizationContext(new NonPumpingSynchronizationContext(current));
                ISynchronizer sychronizer = Synchronizer;
                if (sychronizer != null)
                {
                    Console.WriteLine("AppLoader.Run", "Bootstrapper starts running ThreadSynchronizer.");
                    sychronizer.Run(m_MainApplicationForm);
                    Console.WriteLine("AppLoader.Run", "Bootstrapper finished running ThreadSynchronizer.");
                }
                else
                {
                    Application.Run(m_MainApplicationForm);
                }
            }
            finally
            {
                SynchronizationContext.SetSynchronizationContext(current);
            }
        }