From 1a8548e5b96d45f9be837736257fce6f67a367fb Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 7 Jan 2019 22:01:43 -0600 Subject: [PATCH] Changed thread affinity of some timer objects --- DS4Windows/DS4Forms/DS4Form.cs | 47 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 07209fc..b48dcbb 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -37,8 +37,8 @@ namespace DS4Windows private ToolStripMenuItem[] shortcuts; private ToolStripMenuItem[] disconnectShortcuts; protected CheckBox[] linkedProfileCB; - NonFormTimer hotkeysTimer = new NonFormTimer(); - NonFormTimer autoProfilesTimer = new NonFormTimer(); + NonFormTimer hotkeysTimer = null;// new NonFormTimer(); + NonFormTimer autoProfilesTimer = null;// new NonFormTimer(); string tempProfileProgram = string.Empty; double dpix, dpiy; List profilenames = new List(); @@ -249,16 +249,10 @@ namespace DS4Windows */ //tabProfiles.Controls.Add(opt); - //autoProfilesTimer.Elapsed += CheckAutoProfiles; - autoProfilesTimer.Interval = 1000; - autoProfilesTimer.AutoReset = false; - FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version = fvi.FileVersion; LogDebug(DateTime.Now, "DS4Windows version " + version, false); - LoadP(); - Global.BatteryStatusChange += BatteryStatusUpdate; Global.ControllerRemoved += ControllerRemovedChange; Global.DeviceStatusChange += DeviceStatusChanged; @@ -270,17 +264,9 @@ namespace DS4Windows Enable_Controls(3, false); btnStartStop.Text = Properties.Resources.StartText; - //hotkeysTimer.Elapsed += Hotkeys; - hotkeysTimer.AutoReset = false; - if (SwipeProfiles) - { - ChangeHotkeysStatus(true); - //hotkeysTimer.Start(); - } - startToolStripMenuItem.Text = btnStartStop.Text; cBoxNotifications.SelectedIndex = Notifications; - cBSwipeProfiles.Checked = SwipeProfiles; + //cBSwipeProfiles.Checked = SwipeProfiles; int checkwhen = CheckWhen; cBUpdate.Checked = checkwhen > 0; if (checkwhen > 23) @@ -419,6 +405,33 @@ namespace DS4Windows this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked())); }); } + + Thread timerThread = new Thread(() => + { + hotkeysTimer = new NonFormTimer(); + //hotkeysTimer.Elapsed += Hotkeys; + hotkeysTimer.AutoReset = false; + if (SwipeProfiles) + { + ChangeHotkeysStatus(true); + //hotkeysTimer.Start(); + } + + autoProfilesTimer = new NonFormTimer(); + //autoProfilesTimer.Elapsed += CheckAutoProfiles; + autoProfilesTimer.Interval = 1000; + autoProfilesTimer.AutoReset = false; + + LoadP(); + + this.BeginInvoke((System.Action)(() => + { + cBSwipeProfiles.Checked = SwipeProfiles; + })); + }); + timerThread.IsBackground = true; + timerThread.Priority = ThreadPriority.Lowest; + timerThread.Start(); } private void populateHoverTextDict()