public async Task StartBroadcastHandlers() { if (Config.UpdateSelf == true) { var officialExe = CurrentExe.GetFullPath(); if (await _verWatchr.NewVersionInstalled("FC-Updater")) { CurrentExe.Shutdown(); Process.Start(officialExe); } await StartNewHandler <BinaryFileChangeBroadcastHandlerVM>( CheckerRelease.FileKey, CurrentExe.GetFullPath()); } await SetFirebaseHandler(); foreach (var kv in Config.BinaryFiles) { await StartNewHandler <BinaryFileChangeBroadcastHandlerVM>(kv.Key, kv.Value); } foreach (var kv in Config.AppendOnlyDBs) { await StartNewHandler <AppendOnlyDbChangeBroadcastHandlerVM>(kv.Key, kv.Value); } foreach (var kv in Config.Executables) { await StartNewHandler <BinaryFileChangeBroadcastHandlerVM>(kv.Key, kv.Value); } }
private static void ExitOnError(Action action, string context) { try { action.Invoke(); } catch (Exception ex) { OnError(ex, context); CurrentExe.Shutdown(); } }
private static void SafeExecute(Action action, string context) { try { action.Invoke(); } catch (Exception ex) { Alert.Show(ex, context); CurrentExe.Shutdown(); } }
private static void SafeExecute(Action <AppArguments> action, AppArguments args) { try { action.Invoke(args); } catch (Exception ex) { //Log.Error(ex.Info(true, true)); Alert.Show(ex, "Initialize -> SafeExecute"); CurrentExe.Shutdown(); } }
public static T ShowMainWindow <T>(this ILifetimeScope scope, bool hideOnWindowClose = false) where T : Window, new() { if (!scope.TryResolveOrAlert <MainWindowVmBase>(out MainWindowVmBase vm)) { CurrentExe.Shutdown(); return(null); } var win = new T(); vm.HandleWindowEvents(win, scope, hideOnWindowClose); win.Show(); return(win); }
private static async void Vm_OnWindowHidden(object sender, EventArgs e) { if (_isChecking) { return; } _isChecking = true; var oldExe = CurrentExe.GetFullPath(); if (await _vChkr.NewVersionInstalled(_fileKey)) { CurrentExe.Shutdown(); Process.Start(oldExe); } _isChecking = false; }
private async Task RequestAndWait() { BadMessage = ""; StartBeingBusy(Default.RequestingMessage); if (await SendAndCheckTwice()) { MessageBox.Show("Target received the request."); CurrentExe.Shutdown(); } else { BadMessage = "Target did not respond to the request."; } StopBeingBusy(); }
private async Task ExitApp(bool relaunchAfter) { try { OnWindowClose(); await OnWindowCloseAsync(); _scope?.Dispose(); AppInsights.Flush(); if (relaunchAfter) { CurrentExe.RelaunchApp(); } else { CurrentExe.Shutdown(); } } catch { } }
public bool?Show <T>(bool hideWindow = false, bool showModal = false) where T : Window, new() { if (ShouldClose) { Alert.ShowModal("Exiting ...", WhyShouldClose); CurrentExe.Shutdown(); return(false); } _win = new T(); ApplyWindowTheme(_win); _win.DataContext = this; _win.MakeDraggable(); _win.WindowStartupLocation = WindowStartupLocation.CenterScreen; _win.SnapsToDevicePixels = true; _win.Loaded += (s, e) => OnWindowLoaded(); _win.Closing += async(s, e) => await OnWindowClosing(e); #if DEBUG _win.SetToCloseOnEscape(); _win.WindowState = WindowState.Normal; #endif if (showModal) { return(_win.ShowDialog()); } else { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed _win.ShowTemporarilyOnTop(); #pragma warning restore CS4014 if (hideWindow) { _win.Hide(); } return(null); } }