Trim event handler method. Add name for timeout threads.

Decent performance boost with this change
This commit is contained in:
Travis Nickles 2017-08-21 05:25:18 -05:00
parent dce5c811f2
commit 5df34b8378
2 changed files with 18 additions and 30 deletions

View File

@ -23,8 +23,6 @@ namespace DS4Windows
public string[] arguements; public string[] arguements;
delegate void LogDebugDelegate(DateTime Time, String Data, bool warning); delegate void LogDebugDelegate(DateTime Time, String Data, bool warning);
delegate void NotificationDelegate(object sender, DebugEventArgs args); delegate void NotificationDelegate(object sender, DebugEventArgs args);
delegate void BatteryStatusDelegate(object sender, BatteryReportArgs args);
delegate void ControllerRemovedDelegate(object sender, ControllerRemovedArgs args);
delegate void DeviceStatusChangedDelegate(object sender, DeviceStatusChangeEventArgs args); delegate void DeviceStatusChangedDelegate(object sender, DeviceStatusChangeEventArgs args);
delegate void DeviceSerialChangedDelegate(object sender, SerialChangeArgs args); delegate void DeviceSerialChangedDelegate(object sender, SerialChangeArgs args);
protected Label[] Pads, Batteries; protected Label[] Pads, Batteries;
@ -1064,39 +1062,27 @@ namespace DS4Windows
protected void BatteryStatusUpdate(object sender, BatteryReportArgs args) protected void BatteryStatusUpdate(object sender, BatteryReportArgs args)
{ {
if (this.InvokeRequired) string battery;
int level = args.getLevel();
bool charging = args.isCharging();
int Index = args.getIndex();
if (charging)
{ {
try if (level >= 100)
{ battery = Properties.Resources.Full;
BatteryStatusDelegate d = new BatteryStatusDelegate(BatteryStatusUpdate); else
this.BeginInvoke(d, new object[] { sender, args }); battery = level + "%+";
}
catch { }
} }
else else
{ {
string battery; battery = level + "%";
int level = args.getLevel();
bool charging = args.isCharging();
int Index = args.getIndex();
if (charging)
{
if (level >= 100)
battery = Properties.Resources.Full;
else
battery = level + "%+";
}
else
{
battery = level + "%";
}
Batteries[args.getIndex()].Text = battery;
// Update device battery level display for tray icon
generateDeviceNotifyText(args.getIndex());
populateNotifyText();
} }
Batteries[args.getIndex()].Text = battery;
// Update device battery level display for tray icon
generateDeviceNotifyText(args.getIndex());
populateNotifyText();
} }
protected void populateFullNotifyText() protected void populateFullNotifyText()

View File

@ -483,6 +483,8 @@ namespace DS4Windows
ds4Output.Start(); ds4Output.Start();
timeoutCheckThread = new Thread(timeoutTestThread); timeoutCheckThread = new Thread(timeoutTestThread);
timeoutCheckThread.Priority = ThreadPriority.BelowNormal;
timeoutCheckThread.Name = "DS4 Timeout thread: " + Mac;
timeoutCheckThread.IsBackground = true; timeoutCheckThread.IsBackground = true;
timeoutCheckThread.Start(); timeoutCheckThread.Start();
} }