From de648a72bcef61419066aaf7f9c1e73ee43dd533 Mon Sep 17 00:00:00 2001 From: Bailey Eaton Date: Fri, 2 Jun 2023 13:38:32 +1000 Subject: [PATCH] Introduced a thread sleep to ClearWindow method This is to alleviate race conditions where the command sent to clear whatevers previously drawn on a redraw isn't acknowledged til after the redraw, immediately clearing whatever was drawn. There's probably a better way of doing this - but this works for now. --- src/TED/TED.Utils/Win32Native.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TED/TED.Utils/Win32Native.cs b/src/TED/TED.Utils/Win32Native.cs index 5af941b..9a59166 100644 --- a/src/TED/TED.Utils/Win32Native.cs +++ b/src/TED/TED.Utils/Win32Native.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Threading; namespace TED.Utils { @@ -117,8 +118,9 @@ namespace TED.Utils // The Thread.Sleep() is necessary because the command has a minor delay to it // Without it, the clear will end up running after we've generated a watermark, // removing our newly generated watermark + // Surely there's a better way to do this but for now... this works okay? SendMessage(windowHandle, 0x0034, 4, IntPtr.Zero); - //Thread.Sleep(2000); + Thread.Sleep(2000); } public static IntPtr CreateWorkerW(IntPtr progman)