Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
hot-fix for WPF/WinForms with OpenGL (DX is fine)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Mar 5, 2018
1 parent 3fd7011 commit ea231f9
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Extensions/Urho.Extensions.WinForms/UrhoSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,8 @@ protected override void OnHandleDestroyed(EventArgs e)

public bool Paused
{
get { return paused; }
set
{
paused = value;
if (value)
{
Focuse();
UnderlyingPanel.Visible = true;
UnderlyingPanel.Focus();
}
}
get => paused;
set => paused = value;
}

async void Focuse()
Expand Down Expand Up @@ -75,8 +66,12 @@ public async Task<Application> Show(Type appType, ApplicationOptions opts = null
paused = false;
opts = opts ?? new ApplicationOptions();
await Semaphore.WaitAsync();

if (Application.HasCurrent)
await Application.Current.Exit();
Application.InvokeOnMain(async () => {
if (Application.HasCurrent)
await Application.Current.Exit();
});

RenderThread?.Join();

Expand All @@ -103,6 +98,7 @@ public async Task<Application> Show(Type appType, ApplicationOptions opts = null
var sw = new Stopwatch();

var engine = Application.Engine;
engine.RunFrame();
while (Application.IsActive)
{
if (!Paused)
Expand Down Expand Up @@ -132,7 +128,12 @@ public async Task<Application> Show(Type appType, ApplicationOptions opts = null

public void Stop()
{
Application?.Exit();
Application.InvokeOnMain(async () => {
if (Application.HasCurrent)
await Application.Current.Exit();
});

RenderThread?.Join();
Controls.Clear();
}

Expand Down

0 comments on commit ea231f9

Please sign in to comment.