probably remove startup bottleneck
This commit is contained in:
parent
dc7b0660fc
commit
808826fdc9
2 changed files with 22 additions and 7 deletions
|
|
@ -53,8 +53,6 @@ public class AdbService : IAdbService
|
||||||
|
|
||||||
if (File.Exists(adbPath)) return adbPath;
|
if (File.Exists(adbPath)) return adbPath;
|
||||||
ExtractResource("MetaforceInstaller.Core.adb.adb.exe", adbPath);
|
ExtractResource("MetaforceInstaller.Core.adb.adb.exe", adbPath);
|
||||||
ExtractResource("MetaforceInstaller.Core.adb.AdbWinApi.dll", Path.Combine(tempDir, "AdbWinApi.dll"));
|
|
||||||
ExtractResource("MetaforceInstaller.Core.adb.AdbWinUsbApi.dll", Path.Combine(tempDir, "AdbWinUsbApi.dll"));
|
|
||||||
|
|
||||||
return adbPath;
|
return adbPath;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
|
|
@ -31,10 +32,7 @@ public partial class MainWindow : Window
|
||||||
VersionTextBlock.Text = Assembly.GetExecutingAssembly()
|
VersionTextBlock.Text = Assembly.GetExecutingAssembly()
|
||||||
.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version;
|
.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version;
|
||||||
|
|
||||||
|
_ = InitializeAdbAsync();
|
||||||
_adbService = new AdbService();
|
|
||||||
_adbService.ProgressChanged += OnAdbProgressChanged;
|
|
||||||
_adbService.StatusChanged += OnAdbStatusChanged;
|
|
||||||
|
|
||||||
CheckAndEnableInstallButton();
|
CheckAndEnableInstallButton();
|
||||||
|
|
||||||
|
|
@ -43,6 +41,19 @@ public partial class MainWindow : Window
|
||||||
InstallButton.Click += OnInstallClicked;
|
InstallButton.Click += OnInstallClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task InitializeAdbAsync()
|
||||||
|
{
|
||||||
|
LogMessage("Инициализация ADB сервера...");
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
_adbService = new AdbService();
|
||||||
|
_adbService.ProgressChanged += OnAdbProgressChanged;
|
||||||
|
_adbService.StatusChanged += OnAdbStatusChanged;
|
||||||
|
});
|
||||||
|
|
||||||
|
LogMessage("ADB сервер готов");
|
||||||
|
}
|
||||||
|
|
||||||
private void OnAdbProgressChanged(object? sender, ProgressInfo e)
|
private void OnAdbProgressChanged(object? sender, ProgressInfo e)
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
|
@ -182,6 +193,12 @@ public partial class MainWindow : Window
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_adbService == null)
|
||||||
|
{
|
||||||
|
LogMessage("ADB сервис еще инициализируется, попробуйте позже");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_adbService.RefreshDeviceData();
|
_adbService.RefreshDeviceData();
|
||||||
|
|
||||||
InstallButton.IsEnabled = false;
|
InstallButton.IsEnabled = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue