From 890ae6cef9b44fed006e11deeb68618d1f3bf314 Mon Sep 17 00:00:00 2001 From: yuzh <46953451+yuzh0816@users.noreply.github.com> Date: Thu, 21 Nov 2024 17:37:08 +0800 Subject: [PATCH] feat: Close adb and hdc when ending application. --- UotanToolbox/MainView.axaml.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/UotanToolbox/MainView.axaml.cs b/UotanToolbox/MainView.axaml.cs index 312de1cb..8be0b9dd 100644 --- a/UotanToolbox/MainView.axaml.cs +++ b/UotanToolbox/MainView.axaml.cs @@ -7,6 +7,7 @@ using SukiUI.Controls; using SukiUI.Models; using System; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; @@ -123,6 +124,22 @@ private void InitializeComponent() SettingsViewModel settingsViewModel = new SettingsViewModel(); Settings.Default.IsLightTheme = settingsViewModel.IsLightTheme; Settings.Default.Save(); + KillProcess("adb"); + KillProcess("hdc"); }; } + + private static void KillProcess(string processName) + { + foreach (var process in Process.GetProcessesByName(processName)) + { + try + { + process.Kill(); + process.WaitForExit(); + } + catch (Win32Exception ex){} + catch (InvalidOperationException){} + } + } }