Пример #1
0
        public async Task <Application> Show(Type appType, ApplicationOptions opts = null)
        {
            LogSharp.Debug("UrhoSurface: Show.");
            await waitWhileSuperviewIsNullTaskSource.Task;

            UrhoPlatformInitializer.DefaultInit();
            await Task.Yield();

            paused = false;
            opts   = opts ?? new ApplicationOptions();
            LogSharp.Debug("UrhoSurface: Show. Wait semaphore.");
            await Semaphore.WaitAsync();

            //await Stop();
            if (Application.HasCurrent)
            {
                await Application.Current.Exit();
            }
            await Task.Yield();

            SDL_SetExternalViewPlaceholder(Handle, Window.Handle);

            Hidden = true;
            var app = Application.CreateInstance(appType, opts);

            Application = app;
            app.Run();
            Semaphore.Release();
            await Application.ToMainThreadAsync();

            InvokeOnMainThread(() => Hidden = false);
            LogSharp.Debug("UrhoSurface: Finished.");
            return(app);
        }
Пример #2
0
 public static void StopRendering(Application app)
 {
     LogSharp.Debug("UrhoSurface: StopRendering.");
     Resume();
     if (Application.HasCurrent && Application.Current.Graphics?.IsDeleted != true)
     {
         var window = Application.Current.Graphics.SdlWindow;
         if (window != IntPtr.Zero)
         {
             LogSharp.Debug("UrhoSurface: UIKit_StopRenderLoop.");
             UIKit_StopRenderLoop(window);
         }
     }
     LogSharp.Debug("UrhoSurface: Finished.");
 }
Пример #3
0
        public async Task Stop()
        {
            LogSharp.Debug("UrhoSurface: Stop.");
            if (Application == null || !Application.IsActive)
            {
                return;
            }

            LogSharp.Debug("UrhoSurface: Stop. Wait semaphore.");
            await ExitSemaphore.WaitAsync();

            LogSharp.Debug("UrhoSurface: Stop. Exiting...");
            await Application.Exit();

            LogSharp.Debug("UrhoSurface: Stop. Removing subviews...");
            foreach (var view in Subviews)
            {
                view.RemoveFromSuperview();
            }
            ExitSemaphore.Release();
            LogSharp.Debug("UrhoSurface: Stop. Finished.");
        }