Ejemplo n.º 1
0
 public static void StopServer()
 {
     AegisTask.Run(() =>
     {
         Aegis.Framework.Release();
     });
 }
Ejemplo n.º 2
0
        public static void StartServer(System.Windows.Forms.TextBox tb)
        {
            if (tb != null)
            {
                LogMedia.SetTextBoxLogger(tb);
            }


            AegisTask.Run(() =>
            {
                //  Initialize AegisFramework
                Framework.Initialized += Framework_Initialized;
                Framework.Running     += Framework_Running;
                Framework.Finalizing  += Framework_Finalizing;
                Framework.Finalized   += Framework_Finalized;
                Framework.Initialize(false);
            });
        }
Ejemplo n.º 3
0
        public static void Initialize()
        {
            string[] args = Environment.GetCommandLineArgs();


            //  프레임워크 초기화
            {
                SpinWorker.Initialize();


                _stopRunningEvent = new EventWaitHandle(false, EventResetMode.ManualReset);
                _releaseEvent     = new EventWaitHandle(false, EventResetMode.ManualReset);
                Logger.Info(LogMask.Aegis, "Aegis Framework({0})", AegisVersion.ToString(3));
            }



            AegisTask.Run(() =>
            {
                //  컨텐츠 초기화 (UI 모드)
                if (Environment.UserInteractive)
                {
                    AegisTask.SafeAction(() =>
                    {
                        if (Initialized == null ||
                            Initialized.Invoke(args) == true)
                        {
                            Running?.Invoke();
                        }
                    });

                    AegisTask.SafeAction(() => { Finalizing?.Invoke(CloseReason.Close); });
                }
                //  컨텐츠 초기화 (서비스 모드)
                else
                {
                    ServiceMain.Instance.EventStart = () =>
                    {
                        AegisTask.SafeAction(() =>
                        {
                            if (Initialized == null ||
                                Initialized?.Invoke(System.Environment.GetCommandLineArgs()) == true)
                            {
                                //  Running이 설정된 경우에는 Running이 반환되기를 대기하고, 반환된 후 종료처리 진행
                                if (Running != null)
                                {
                                    (new Thread(() =>
                                    {
                                        AegisTask.SafeAction(() => { Running.Invoke(); });
                                        ServiceMain.Instance.Stop();
                                    })).Start();
                                }
                            }
                        });
                    };
                    ServiceMain.Instance.EventStop = () =>
                    {
                        AegisTask.SafeAction(() => { Finalizing?.Invoke(CloseReason.ServiceStop); });
                    };
                    ServiceMain.Instance.EventShutDown = () =>
                    {
                        AegisTask.SafeAction(() => { Finalizing?.Invoke(CloseReason.ShutDown); });
                    };
                    ServiceMain.Instance.Run();
                }


                _stopRunningEvent.Set();
            });


            AegisTask.Run(() =>
            {
                WaitForRunning();


                //  프레임워크 종료
                Calculate.IntervalTimer.DisposeAll();
                NamedThread.DisposeAll();
                NamedObjectManager.Clear();
                SpinWorker.Release();


                Logger.Info(LogMask.Aegis, "Aegis Framework finalized.");
                Logger.RemoveAll();


                AegisTask.SafeAction(() => { Finalized?.Invoke(); });
                Initialized = null;
                Finalizing  = null;
                Finalized   = null;
                Running     = null;

                _releaseEvent.Set();
            });
        }