From 4da017ca14c8682829349f35e305985eb2e510ce Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 15 Feb 2020 08:28:19 -0800 Subject: [PATCH] Check InputActionsThread before queueing. --- ScreenCast.Win/Services/WinInput.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ScreenCast.Win/Services/WinInput.cs b/ScreenCast.Win/Services/WinInput.cs index 00c5a363..4bcbaf7c 100644 --- a/ScreenCast.Win/Services/WinInput.cs +++ b/ScreenCast.Win/Services/WinInput.cs @@ -15,6 +15,12 @@ namespace Remotely.ScreenCast.Win.Services { public WinInput() { + StartInputActionThread(); + } + + private void StartInputActionThread() + { + InputActionsThread?.Abort(); InputActionsThread = new Thread(() => { while (true) @@ -31,7 +37,7 @@ namespace Remotely.ScreenCast.Win.Services } private ConcurrentQueue InputActions { get; } = new ConcurrentQueue(); - private Thread InputActionsThread { get; } + private Thread InputActionsThread { get; set; } private bool IsInputBlocked { get; set; } public Tuple GetAbsolutePercentFromRelativePercent(double percentX, double percentY, ICapturer capturer) { @@ -317,6 +323,11 @@ namespace Remotely.ScreenCast.Win.Services private void TryOnInputDesktop(Action inputAction) { + if (!InputActionsThread.IsAlive) + { + StartInputActionThread(); + } + InputActions.Enqueue(() => { if (!Win32Interop.SwitchToInputDesktop())