@@ -17,6 +17,7 @@ public partial class aboutPanel : UserControl
1717 private string _latestVersion , _lastCheckedBranch ;
1818 private bool _updateThreadRunning = false ;
1919 private bool _updateUI = false ;
20+ private bool _isUpdate = false ;
2021
2122 private Action _onIsUpdateAction ;
2223
@@ -26,9 +27,7 @@ public aboutPanel()
2627
2728 miscVersionLabel . Text = String . Format ( "FAES Version: {0}\n \r SSM Version: {1}" , ConvertVersionToFormatted ( FAES . FileAES_Utilities . GetVersion ( ) ) , ConvertVersionToFormatted ( SimpleSettingsManager . SSM . GetVersion ( ) ) ) ;
2829 GetCurrentVersion ( ) ;
29- CheckForUpdate ( ) ;
3030 }
31-
3231 public enum UpdateStatus
3332 {
3433 ServerError ,
@@ -37,6 +36,11 @@ public enum UpdateStatus
3736 AppNewer
3837 } ;
3938
39+ public bool IsUpdate ( )
40+ {
41+ return _isUpdate ;
42+ }
43+
4044 private void GetCurrentVersion ( )
4145 {
4246 currentVerLabel . Text = Program . GetVersion ( ) ;
@@ -69,6 +73,7 @@ private void UpdateUI()
6973 reinstallCurrentButton . Enabled = true ;
7074 updateDescLabel . Text = "You are on the latest version!" ;
7175 latestVerLabel . Text = latestVersion ;
76+ _isUpdate = false ;
7277
7378 Logging . Log ( String . Format ( "FAES_GUI(AboutPanel): UpdateUI set to AppLatest." ) , Severity . DEBUG ) ;
7479 }
@@ -82,6 +87,7 @@ private void UpdateUI()
8287 reinstallCurrentButton . Enabled = false ;
8388 updateDescLabel . Text = "You are on a private build." ;
8489 latestVerLabel . Text = latestVersion ;
90+ _isUpdate = false ;
8591
8692 Logging . Log ( String . Format ( "FAES_GUI(AboutPanel): UpdateUI set to AppNewer." ) , Severity . DEBUG ) ;
8793 }
@@ -95,6 +101,7 @@ private void UpdateUI()
95101 reinstallCurrentButton . Enabled = false ;
96102 updateDescLabel . Text = "Unable to connect to the update server." ;
97103 latestVerLabel . Text = "SERVER ERROR!" ;
104+ _isUpdate = false ;
98105
99106 Logging . Log ( String . Format ( "FAES_GUI(AboutPanel): UpdateUI set to ServerError." ) , Severity . DEBUG ) ;
100107 }
@@ -108,6 +115,7 @@ private void UpdateUI()
108115 reinstallCurrentButton . Enabled = true ;
109116 updateDescLabel . Text = "An update is available!" ;
110117 latestVerLabel . Text = latestVersion ;
118+ _isUpdate = true ;
111119
112120 Logging . Log ( String . Format ( "FAES_GUI(AboutPanel): UpdateUI set to AppOutdated." ) , Severity . DEBUG ) ;
113121 }
@@ -161,32 +169,45 @@ private bool DoesVersionExist(string version, string branch)
161169
162170 public void CheckForUpdate ( )
163171 {
164- if ( ! _updateThreadRunning )
172+ try
165173 {
166- _updateThreadRunning = true ;
167-
168- Thread threaddedUpdateCheck = new Thread ( ( ) =>
174+ if ( ! _updateThreadRunning )
169175 {
170- string updateVersion ;
176+ _updateThreadRunning = true ;
171177
172- Logging . Log ( String . Format ( "Checking for update..." ) , Severity . DEBUG ) ;
173- UpdateStatus updateInfo = GetUpdateStatus ( out updateVersion ) ;
178+ Thread threaddedUpdateCheck = new Thread ( ( ) =>
179+ {
180+ try
181+ {
182+ string updateVersion ;
174183
175- if ( updateVersion != "v0.0.0" )
176- Logging . Log ( String . Format ( "Latest FAES_GUI version: {0}" , updateVersion ) , Severity . DEBUG ) ;
177- else
178- Logging . Log ( String . Format ( "Update check failed!" ) , Severity . WARN ) ;
184+ Logging . Log ( String . Format ( "Checking for update..." ) , Severity . DEBUG ) ;
185+ UpdateStatus updateInfo = GetUpdateStatus ( out updateVersion ) ;
179186
180- _appUpdateStatus = updateInfo ;
181- _latestVersion = updateVersion ;
182- _lastCheckedBranch = Program . programManager . GetBranch ( ) ;
183- _updateUI = true ;
184- _updateThreadRunning = false ;
187+ if ( updateVersion != "v0.0.0" )
188+ Logging . Log ( String . Format ( "Latest FAES_GUI version: {0}" , updateVersion ) , Severity . DEBUG ) ;
189+ else
190+ Logging . Log ( String . Format ( "Update check failed!" ) , Severity . WARN ) ;
185191
186- if ( _appUpdateStatus == UpdateStatus . AppOutdated && ! Program . programManager . GetSkipUpdates ( ) ) DoIsUpdateAction ( ) ;
187- } ) ;
188- threaddedUpdateCheck . Start ( ) ;
192+ _appUpdateStatus = updateInfo ;
193+ _latestVersion = updateVersion ;
194+ _lastCheckedBranch = Program . programManager . GetBranch ( ) ;
195+ _updateUI = true ;
196+ _updateThreadRunning = false ;
197+
198+ if ( _appUpdateStatus == UpdateStatus . AppOutdated && ! Program . programManager . GetSkipUpdates ( ) ) DoIsUpdateAction ( ) ;
199+ }
200+ catch { } // Hacky solution to stop VS2019 crashing when viewing some forms...
201+ } ) ;
202+ threaddedUpdateCheck . Start ( ) ;
203+ }
189204 }
205+ catch { } // Hacky solution to stop VS2019 crashing when viewing some forms...
206+ }
207+
208+ public bool IsUpdateCheckRunning ( )
209+ {
210+ return _updateThreadRunning ;
190211 }
191212
192213 public void SetIsUpdateAction ( Action action )
@@ -427,8 +448,12 @@ private static void RunAsAdmin()
427448
428449 private void Runtime_Tick ( object sender , EventArgs e )
429450 {
430- if ( _updateThreadRunning || _updateUI ) UpdateUI ( ) ;
431- if ( Program . programManager . GetBranch ( ) != _lastCheckedBranch ) CheckForUpdate ( ) ;
451+ try
452+ {
453+ if ( _updateThreadRunning || _updateUI ) UpdateUI ( ) ;
454+ if ( Program . programManager . GetBranch ( ) != _lastCheckedBranch ) CheckForUpdate ( ) ;
455+ }
456+ catch { } // Hacky solution to stop VS2019 crashing when viewing some forms...
432457 }
433458
434459 private void UpdatePanel_Paint ( object sender , PaintEventArgs e )
0 commit comments