Change how abort clause is handled for unhandled input thread exceptions

This commit is contained in:
Travis Nickles 2020-03-24 17:06:42 -05:00
parent 3eb15f1500
commit 40c0a58ab1
3 changed files with 21 additions and 3 deletions

View File

@ -188,6 +188,7 @@ namespace DS4WinWPF
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
rootHub.PrepareAbort();
CleanShutdown(); CleanShutdown();
}); });
} }

View File

@ -688,6 +688,18 @@ namespace DS4Windows
} }
} }
public void PrepareAbort()
{
for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++)
{
DS4Device tempDevice = DS4Controllers[i];
if (tempDevice != null)
{
tempDevice.PrepareAbort();
}
}
}
public bool Stop(bool showlog = true) public bool Stop(bool showlog = true)
{ {
if (running) if (running)

View File

@ -608,9 +608,8 @@ namespace DS4Windows
try try
{ {
exitInputThread = true; exitInputThread = true;
if (ds4Input.ThreadState.HasFlag(System.Threading.ThreadState.WaitSleepJoin)) //ds4Input.Interrupt();
ds4Input.Interrupt(); if (!abortInputThread)
else
ds4Input.Join(); ds4Input.Join();
} }
catch (Exception e) catch (Exception e)
@ -1582,5 +1581,11 @@ namespace DS4Windows
{ {
return !test.Equals(blankSerial); return !test.Equals(blankSerial);
} }
private bool abortInputThread = false;
public void PrepareAbort()
{
abortInputThread = true;
}
} }
} }