コード例 #1
0
ファイル: UrhoSurface.cs プロジェクト: DskowFromCrs/urho
        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();
            if (!opts.DelayedStart)
            {
                await Application.ToMainThreadAsync();
            }
            InvokeOnMainThread(() => Hidden = false);
            Urho.Application.CurrentSurface = new WeakReference(this);
            Urho.Application.CurrentWindow  = new WeakReference(Window);
            LogSharp.Debug("UrhoSurface: Finished.");
            return(app);
        }