threading fix

main
cosmonaut 2022-02-09 21:25:16 -08:00
parent d431c5bd6d
commit f6f44eb658
1 changed files with 10 additions and 6 deletions

View File

@ -48,11 +48,15 @@ namespace MoonWorksMultiWindow
protected override void Draw(System.TimeSpan dt, double alpha) protected override void Draw(System.TimeSpan dt, double alpha)
{ {
Task mainDraw = Task.Run(MainDraw); var mainDraw = Task.Run(MainDraw);
Task extraDraw = Task.Run(ExtraWindowDraw); 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(); var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
@ -77,10 +81,10 @@ namespace MoonWorksMultiWindow
Window Window
); );
GraphicsDevice.Submit(commandBuffer); return commandBuffer;
} }
private void ExtraWindowDraw() private CommandBuffer ExtraWindowDraw()
{ {
var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
@ -105,7 +109,7 @@ namespace MoonWorksMultiWindow
ExtraWindow ExtraWindow
); );
GraphicsDevice.Submit(commandBuffer); return commandBuffer;
} }
} }
} }