diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index f97bbd1..28887e9 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -1118,7 +1118,11 @@ namespace DS4Windows lag[ind] = false; inWarnMonitor[ind] = false; useDInputOnly[ind] = true; - OnControllerRemoved(this, ind); + uiContext?.Post(new SendOrPostCallback((state) => + { + OnControllerRemoved(this, ind); + }), null); + //Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME); } } } diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 07b0dca..35f8e83 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -2174,14 +2174,15 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question FormLocationX = Location.X > 0 ? Location.X : 0; FormLocationY = Location.Y > 0 ? Location.Y : 0; + Global.ControllerRemoved -= ControllerRemovedChange; if (!string.IsNullOrEmpty(appdatapath)) { Save(); blankControllerTab(); - Program.rootHub.Stop(); } + TaskRunner.Run(() => Program.rootHub.Stop()).Wait(); // Make sure to stop event generation routines. Should fix odd crashes on shutdown Application.Exit(); }