From f6f44eb6583491fc8e54c0b494f4be4f842e1b57 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 9 Feb 2022 21:25:16 -0800 Subject: [PATCH] threading fix --- src/MoonWorksMultiWindowGame.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/MoonWorksMultiWindowGame.cs b/src/MoonWorksMultiWindowGame.cs index 80ca2f5..b12d032 100644 --- a/src/MoonWorksMultiWindowGame.cs +++ b/src/MoonWorksMultiWindowGame.cs @@ -48,11 +48,15 @@ namespace MoonWorksMultiWindow protected override void Draw(System.TimeSpan dt, double alpha) { - Task mainDraw = Task.Run(MainDraw); - Task extraDraw = Task.Run(ExtraWindowDraw); + var mainDraw = Task.Run(MainDraw); + var extraDraw = Task.Run(ExtraWindowDraw); + + mainDraw.Wait(); + extraDraw.Wait(); + GraphicsDevice.Submit(mainDraw.Result, extraDraw.Result); } - private void MainDraw() + private CommandBuffer MainDraw() { var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); @@ -77,10 +81,10 @@ namespace MoonWorksMultiWindow Window ); - GraphicsDevice.Submit(commandBuffer); + return commandBuffer; } - private void ExtraWindowDraw() + private CommandBuffer ExtraWindowDraw() { var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); @@ -105,7 +109,7 @@ namespace MoonWorksMultiWindow ExtraWindow ); - GraphicsDevice.Submit(commandBuffer); + return commandBuffer; } } }