Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Use manualresetevent timeout as a precaution
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryochan7 committed Dec 20, 2023
1 parent 483c366 commit ab9fd05
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions DS4Windows/DS4Library/DS4Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1989,20 +1989,23 @@ public void queueEvent(Action act)
public void HaltReportingRunAction(Action act)
{
// Wait for controller to be in a wait period
readWaitEv.Wait();
readWaitEv.Reset();
bool result = readWaitEv.Wait(millisecondsTimeout: 500);
if (result)
{
readWaitEv.Reset();

// Tell device to no longer fire reports
fireReport = false;
// Tell device to no longer fire reports
fireReport = false;

// Flag is set. Allow input thread to resume
readWaitEv.Set();
// Flag is set. Allow input thread to resume
readWaitEv.Set();

// Invoke main desired action
act?.Invoke();
// Invoke main desired action
act?.Invoke();

// Start firing reports again
fireReport = true;
// Start firing reports again
fireReport = true;
}
}

public void updateSerial()
Expand Down

0 comments on commit ab9fd05

Please sign in to comment.