feat: manage multiple desktop device connections independently
This commit is contained in:
1 parent
08d60de364
commit
05d4d5fea6
12 files changed
+504
-249
No files matched your search
@@ -6,7 +6,7 @@ using Microsoft.Win32;
|
||||
namespace Ads.Desktop;
|
||||
|
||||
/// <summary>Owns one loopback USB/IP export and its exact imported hub port.</summary>
|
||||
public sealed class WindowsUsbSession
|
||||
public sealed class WindowsUsbSession : IDisposable
|
||||
{
|
||||
private Process? bridge;
|
||||
private string? usbip;
|
||||
@@ -59,6 +59,12 @@ public sealed class WindowsUsbSession
|
||||
hubPort = importedPort;
|
||||
log($"USB ADB 已挂载:{Serial},本机控制器端口 {hubPort}。");
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
var current = bridge; bridge = null;
|
||||
try { if (current != null && !current.HasExited) current.Kill(entireProcessTree: true); } catch { }
|
||||
current?.Dispose(); hubPort = null;
|
||||
}
|
||||
public async Task StopAsync(Action<string> log)
|
||||
{
|
||||
// Closing our export first forces the driver to remove this device even if detach fails.
|
||||
|
||||
Reference in new issue
Block a user