From 1ff066fcf9223d1ffd7e1dffb4b9ab21648d1351 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 12 Oct 2018 02:24:55 -0500 Subject: [PATCH] Enforce static for SystemEvents.PowerModeChanged Faster performance --- DS4Windows/DS4Forms/DS4Form.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index e9c6dbe..086ef32 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -55,6 +55,7 @@ namespace DS4Windows bool turnOffTemp; bool runningBat; private bool changingService; + private static DS4Form instance; Dictionary hoverTextDict = new Dictionary(); // 0 index is used for application version text. 1 - 4 indices are used for controller status string[] notifyText = new string[5] @@ -397,6 +398,7 @@ namespace DS4Windows } } + instance = this; if (btnStartStop.Enabled && start) TaskRunner.Delay(50).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); } @@ -525,29 +527,29 @@ namespace DS4Windows return text.ToString(); } - private void OnPowerChange(object s, PowerModeChangedEventArgs e) + private static void OnPowerChange(object s, PowerModeChangedEventArgs e) { switch (e.Mode) { case PowerModes.Resume: { - if (btnStartStop.Text == Properties.Resources.StartText && wasrunning) + if (instance.btnStartStop.Text == Properties.Resources.StartText && instance.wasrunning) { DS4LightBar.shuttingdown = false; - wasrunning = false; + instance.wasrunning = false; Program.rootHub.suspending = false; - BtnStartStop_Clicked(); + instance.BtnStartStop_Clicked(); } break; } case PowerModes.Suspend: { - if (btnStartStop.Text == Properties.Resources.StopText) + if (instance.btnStartStop.Text == Properties.Resources.StopText) { DS4LightBar.shuttingdown = true; Program.rootHub.suspending = true; - BtnStartStop_Clicked(); - wasrunning = true; + instance.BtnStartStop_Clicked(); + instance.wasrunning = true; } break; }