mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-01-11 15:59:08 +01:00
Correct issue when two threads try to abort ds4Output thread simultaneously
This commit is contained in:
parent
4e33578686
commit
9d190fcaf7
@ -298,7 +298,8 @@ namespace DS4Windows
|
||||
|
||||
public void StopUpdate()
|
||||
{
|
||||
if (ds4Input.ThreadState != System.Threading.ThreadState.Unstarted && ds4Input.ThreadState != System.Threading.ThreadState.Stopped)
|
||||
if (ds4Input.IsAlive && ds4Input.ThreadState != System.Threading.ThreadState.Stopped &&
|
||||
ds4Input.ThreadState != System.Threading.ThreadState.AbortRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -315,7 +316,8 @@ namespace DS4Windows
|
||||
|
||||
private void StopOutputUpdate()
|
||||
{
|
||||
if (ds4Output.ThreadState != System.Threading.ThreadState.Unstarted && ds4Output.ThreadState != System.Threading.ThreadState.Stopped)
|
||||
if (ds4Output.IsAlive && ds4Output.ThreadState != System.Threading.ThreadState.Stopped &&
|
||||
ds4Output.ThreadState != System.Threading.ThreadState.AbortRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -633,7 +635,9 @@ namespace DS4Windows
|
||||
outputReportBuffer.CopyTo(outputReport, 0);
|
||||
try
|
||||
{
|
||||
if (!writeOutput())
|
||||
if (!writeOutput() && ds4Output.IsAlive &&
|
||||
ds4Output.ThreadState != System.Threading.ThreadState.Stopped &&
|
||||
ds4Output.ThreadState != System.Threading.ThreadState.AbortRequested)
|
||||
{
|
||||
Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> encountered synchronous write failure: " + Marshal.GetLastWin32Error());
|
||||
ds4Output.Abort();
|
||||
|
Loading…
x
Reference in New Issue
Block a user