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())