From abafe2ad33f2afd076e208e96e8c05f65ea0643d Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 9 Dec 2022 09:09:28 -0800 Subject: [PATCH] Use STA just in case --- .../Avalonia.Win32/OpenGl/WglGdiResourceManager.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Windows/Avalonia.Win32/OpenGl/WglGdiResourceManager.cs b/src/Windows/Avalonia.Win32/OpenGl/WglGdiResourceManager.cs index 1a87520590..ed40488c70 100644 --- a/src/Windows/Avalonia.Win32/OpenGl/WglGdiResourceManager.cs +++ b/src/Windows/Avalonia.Win32/OpenGl/WglGdiResourceManager.cs @@ -98,11 +98,10 @@ internal class WglGdiResourceManager }; s_WindowClass = UnmanagedMethods.RegisterClassEx(ref wndClassEx); - new Thread(Worker) - { - IsBackground = true, - Name = "Win32 OpenGL HDC manager" - }.Start(); + var th = new Thread(Worker) { IsBackground = true, Name = "Win32 OpenGL HDC manager" }; + // This makes CLR to automatically pump the event queue from WaitOne + th.SetApartmentState(ApartmentState.STA); + th.Start(); }