예제 #1
0
 public static void Start(UserCodeExceptionCatchMode exceptionMode, Func <IHostScreen, UniTask> func)
 {
     ProcessHelper.SingleLaunch(() =>
     {
         _func = func;
         Launch(exceptionMode);
     },
                                () => throw new InvalidOperationException("Multiple engines cannot be started at the same time."));
 }
예제 #2
0
        private static void Launch(UserCodeExceptionCatchMode exceptionMode)
        {
            EngineSetting.UserCodeExceptionCatchMode = exceptionMode;

            try {
                Elffy.Diagnostics.DevEnv.Run();
                Engine.Run();
                var screen = CreateScreen();
                screen.Initialized += OnScreenInitialized;
                CustomSynchronizationContext.Install(out var syncContextReciever);
                screen.Activate();
                while (Engine.HandleOnce())
                {
                    syncContextReciever?.DoAll();
                }
            }
            finally {
                CustomSynchronizationContext.Restore();
                Engine.Stop();
                Elffy.Diagnostics.DevEnv.Stop();
            }
        }