@@ -56,27 +56,31 @@ public Form1()
5656 PackageManager packageManager = new PackageManager ( ) ;
5757 Package currentPackage = packageManager . FindPackageForUser ( string . Empty , Package . Current . Id . FullName ) ;
5858
59- int retries = 0 ;
60- while ( retries < 5 )
59+ while ( true )
6160 {
62- if ( retries > 0 )
63- {
64- labelUpdate . Invoke ( ( Action ) ( ( ) => labelUpdate . Text = labelUpdate . Text + " Retrying..." ) ) ;
65- }
66-
6761 PackageUpdateAvailabilityResult status = currentPackage . CheckUpdateAvailabilityAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
68- labelUpdate . Invoke ( ( Action ) ( ( ) => labelUpdate . Text = status . Availability . ToString ( ) ) ) ;
6962
70- if ( status . Availability == PackageUpdateAvailability . NoUpdates )
63+ if ( status . Availability == PackageUpdateAvailability . Unknown )
7164 {
72- break ;
65+ Thread . Sleep ( TimeSpan . FromSeconds ( 5 ) ) ;
7366 }
67+ else
68+ if ( status . Availability == PackageUpdateAvailability . Error )
69+ {
70+ Thread . Sleep ( TimeSpan . FromSeconds ( 1 ) ) ;
71+ }
72+ else
73+ if ( status . Availability == PackageUpdateAvailability . NoUpdates )
74+ {
75+ labelUpdate . Invoke ( ( Action ) ( ( ) => labelUpdate . Text = status . Availability . ToString ( ) ) ) ;
76+ Thread . Sleep ( TimeSpan . FromMinutes ( 5 ) ) ;
77+ } else
7478 if ( status . Availability == PackageUpdateAvailability . Required || status . Availability == PackageUpdateAvailability . Available )
7579 {
80+ labelUpdate . Invoke ( ( Action ) ( ( ) => labelUpdate . Text = status . Availability . ToString ( ) ) ) ;
7681 buttonUpdate . Invoke ( ( Action ) ( ( ) => buttonUpdate . Visible = true ) ) ;
7782 break ;
7883 }
79- retries ++ ;
8084 }
8185 }
8286 catch ( Exception ex )
@@ -172,7 +176,7 @@ private void buttonOK_Click(object sender, EventArgs e)
172176 }
173177 catch ( Exception ex )
174178 {
175- Log ( ex . ToString ( ) ) ;
179+ Log ( ex . Message ) ;
176180 }
177181 } , _cancellationToken . Token ) . ContinueWith ( _ => {
178182 Log ( "done" ) ;
@@ -236,6 +240,7 @@ private void buttonUpdate_Click(object sender, EventArgs e)
236240 {
237241 buttonOK . Enabled = false ;
238242 buttonCancel . Enabled = false ;
243+ labelUpdate . Text = $ "Updating... Application will automatically restart to the new version.";
239244
240245 new Thread ( ( ) =>
241246 {
0 commit comments