From 2858dce664e72342c0dd56cf3e89fdc465fae8f8 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 17 May 2016 22:23:37 +0100 Subject: [PATCH] Fix #620, part of #614 --- Wox/App.xaml | 3 +-- Wox/App.xaml.cs | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Wox/App.xaml b/Wox/App.xaml index 1d7493d271..c629d8a929 100644 --- a/Wox/App.xaml +++ b/Wox/App.xaml @@ -1,8 +1,7 @@  + Startup="OnStartup"> diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 46831a9809..d2788599a0 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,5 +1,7 @@ using System; using System.Diagnostics; +using System.Threading.Tasks; +using System.Timers; using System.Windows; using Wox.Core; using Wox.Core.Plugin; @@ -53,22 +55,33 @@ namespace Wox API = new PublicAPIInstance(_settings, vm); PluginManager.InitializePlugins(API); - RegisterExitEvents(); - Current.MainWindow = window; Current.MainWindow.Title = Infrastructure.Wox.Name; + + RegisterExitEvents(); + + AutoUpdates(); + window.Show(); }); } - private void OnActivated(object sender, EventArgs e) + private void AutoUpdates() { if (_settings.AutoUpdates) { + // check udpate every 5 hours + var timer = new Timer(1000 * 60 * 60 * 5); + timer.Elapsed += (s, e) => + { + Updater.UpdateApp(); + }; + timer.Start(); + + // check updates on startup Updater.UpdateApp(); } } - private void RegisterExitEvents() { AppDomain.CurrentDomain.ProcessExit += (s, e) => Dispose();