Skip to content

Commit

Permalink
feat: Close adb and hdc when ending application.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzh0816 committed Nov 21, 2024
1 parent dd4c397 commit 890ae6c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions UotanToolbox/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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){}
}
}
}

1 comment on commit 890ae6c

@yuzh0816
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed #51 in this commit.

Please sign in to comment.