File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public Updater(string gitHubRepository)
33
33
34
34
public async Task UpdateAppAsync ( IPublicAPI api , bool silentUpdate = true )
35
35
{
36
- await UpdateLock . WaitAsync ( ) ;
36
+ await UpdateLock . WaitAsync ( ) . ConfigureAwait ( false ) ;
37
37
try
38
38
{
39
39
if ( ! silentUpdate )
@@ -88,9 +88,13 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
88
88
UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
89
89
}
90
90
}
91
- catch ( Exception e ) when ( e is HttpRequestException or WebException or SocketException || e . InnerException is TimeoutException )
91
+ catch ( Exception e )
92
92
{
93
- Log . Exception ( $ "|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e ) ;
93
+ if ( ( e is HttpRequestException or WebException or SocketException || e . InnerException is TimeoutException ) )
94
+ Log . Exception ( $ "|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e ) ;
95
+ else
96
+ Log . Exception ( $ "|Updater.UpdateApp|Error Occurred", e ) ;
97
+
94
98
if ( ! silentUpdate )
95
99
api . ShowMsg ( api . GetTranslation ( "update_flowlauncher_fail" ) ,
96
100
api . GetTranslation ( "update_flowlauncher_check_connection" ) ) ;
Original file line number Diff line number Diff line change 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,7 +85,7 @@ 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
91
// happlebao todo temp fix for instance code logic
@@ -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
}
You can’t perform that action at this time.
0 commit comments