|
1 | 1 | using System;
|
2 | 2 | using System.Diagnostics;
|
3 | 3 | using System.Text;
|
| 4 | +using System.Threading; |
4 | 5 | using System.Threading.Tasks;
|
5 | 6 | using System.Timers;
|
6 | 7 | using System.Windows;
|
@@ -84,14 +85,14 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
|
84 | 85 |
|
85 | 86 | Current.MainWindow = window;
|
86 | 87 | Current.MainWindow.Title = Constant.FlowLauncher;
|
87 |
| - |
| 88 | + |
88 | 89 | HotKeyMapper.Initialize(_mainVM);
|
89 | 90 |
|
90 |
| - // happlebao todo temp fix for instance code logic |
| 91 | + // todo temp fix for instance code logic |
91 | 92 | // load plugin before change language, because plugin language also needs be changed
|
92 | 93 | InternationalizationManager.Instance.Settings = _settings;
|
93 | 94 | InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
|
94 |
| - // main windows needs initialized before theme change because of blur settigns |
| 95 | + // main windows needs initialized before theme change because of blur settings |
95 | 96 | ThemeManager.Instance.Settings = _settings;
|
96 | 97 | ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
97 | 98 |
|
@@ -130,20 +131,17 @@ private void AutoStartup()
|
130 | 131 | //[Conditional("RELEASE")]
|
131 | 132 | private void AutoUpdates()
|
132 | 133 | {
|
133 |
| - Task.Run(async () => |
| 134 | + _ = Task.Run(async () => |
134 | 135 | {
|
135 | 136 | if (_settings.AutoUpdates)
|
136 | 137 | {
|
137 |
| - // check udpate every 5 hours |
138 |
| - var timer = new Timer(1000 * 60 * 60 * 5); |
139 |
| - timer.Elapsed += async (s, e) => |
140 |
| - { |
141 |
| - await _updater.UpdateAppAsync(API); |
142 |
| - }; |
143 |
| - timer.Start(); |
144 |
| - |
145 |
| - // check updates on startup |
| 138 | + // check update every 5 hours |
| 139 | + var timer = new PeriodicTimer(TimeSpan.FromHours(5)); |
146 | 140 | await _updater.UpdateAppAsync(API);
|
| 141 | + |
| 142 | + while (await timer.WaitForNextTickAsync()) |
| 143 | + // check updates on startup |
| 144 | + await _updater.UpdateAppAsync(API); |
147 | 145 | }
|
148 | 146 | });
|
149 | 147 | }
|
|
0 commit comments