File tree Expand file tree Collapse file tree 2 files changed +24
-16
lines changed
Expand file tree Collapse file tree 2 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
4848
4949#if DEBUG
5050#else
51- UpdateHelper . DownloadAndInstallAllUpdates ( ) ;
51+ UpdateHelper . DownloadAndInstallAllUpdatesBackground ( ) ;
5252#endif
5353
5454 CreateFrame ( ) ;
Original file line number Diff line number Diff line change 1- using System ;
1+ using HTools ;
2+ using System ;
23using System . Diagnostics ;
34using System . Threading . Tasks ;
45using Windows . Services . Store ;
@@ -7,28 +8,35 @@ namespace Lavcode.Uwp.Helpers
78{
89 public static class UpdateHelper
910 {
10- public static async Task DownloadAndInstallAllUpdatesAsync ( )
11+ public static async Task < bool > DownloadAndInstallAllUpdatesAsync ( )
1112 {
12- try
13+ var result = false ;
14+ await TaskExtend . Run ( async ( ) =>
1315 {
14- var context = StoreContext . GetDefault ( ) ;
15- var updates = await context . GetAppAndOptionalStorePackageUpdatesAsync ( ) ;
16- if ( updates . Count > 0 )
16+ try
1717 {
18- var downloadResult = await context . RequestDownloadStorePackageUpdatesAsync ( updates ) ;
19- if ( downloadResult . OverallState == StorePackageUpdateState . Completed )
18+ var context = StoreContext . GetDefault ( ) ;
19+ var updates = await context . GetAppAndOptionalStorePackageUpdatesAsync ( ) ;
20+ if ( updates . Count > 0 )
2021 {
21- await context . RequestDownloadAndInstallStorePackageUpdatesAsync ( updates ) ;
22+ var downloadResult = await context . RequestDownloadStorePackageUpdatesAsync ( updates ) ;
23+ if ( downloadResult . OverallState == StorePackageUpdateState . Completed )
24+ {
25+ await context . RequestDownloadAndInstallStorePackageUpdatesAsync ( updates ) ;
26+ }
2227 }
28+ result = updates . Count > 0 ;
2329 }
24- }
25- catch ( Exception ex )
26- {
27- Debug . WriteLine ( ex ) ;
28- }
30+ catch ( Exception ex )
31+ {
32+ Debug . WriteLine ( ex ) ;
33+ result = false ;
34+ }
35+ } ) ;
36+ return result ;
2937 }
3038
31- public static async void DownloadAndInstallAllUpdates ( )
39+ public static async void DownloadAndInstallAllUpdatesBackground ( )
3240 {
3341 await DownloadAndInstallAllUpdatesAsync ( ) ;
3442 }
You can’t perform that action at this time.
0 commit comments