private void NotifyInstallStarted(string mPackage, string dlbl) { lblStatus.Text = $"Starting install of `{mPackage}` to `{dlbl}`."; imgIcon.Source = UiExtensions.GetImage("Resources/installpkg.png"); imgIcon.Visibility = Visibility.Visible; btnInstall.IsEnabled = false; }
private void BtnInstall_OnClick(object sender, RoutedEventArgs e) { string mPackage = GetSelectedPackage(); DeviceData d = GetSelectedDevice(); if (mPackage == null) { return; } if (d == null) { return; } string dlbl = $"{d.Model} {d.Serial}]"; Application.Current.Dispatcher?.Invoke(new Action(() => { NotifyInstallStarted(mPackage, dlbl); })); CheckPrerequisites(d).ContinueWith((t) => { InstallPackage(d, mPackage) .ContinueWith((t1) => { if (t1.IsFaulted) { Application.Current.Dispatcher?.Invoke(new Action(() => { lblStatus.Text = $"Install of `{mPackage}` has failed. Error: {t1.Exception.Message}"; imgIcon.Source = UiExtensions.GetImage("Resources/installfailed.png"); imgIcon.Visibility = Visibility.Visible; lblIcon.Content = "Install failed. Reconnect your device and try again."; btnInstall.IsEnabled = true; })); } else { Application.Current.Dispatcher?.Invoke(new Action(() => { lblStatus.Text = $"Installation done."; imgIcon.Visibility = Visibility.Hidden; btnInstall.IsEnabled = true; })); } }); }); }