@@ -159,46 +159,47 @@ private void LanguageSwitch()
159
159
private async void Update ( bool showError , bool showNoUpdates )
160
160
{
161
161
Language l = _languageManager . GetLanguage ( ) ;
162
- await Task . Run ( ( ) =>
162
+
163
+ try
163
164
{
164
- try
165
- {
166
- WebClient wc = new WebClient ( ) ;
167
- string xml = wc . DownloadString ( "http://codedead.com/Software/DeadLock/update.xml" ) ;
165
+ WebClient wc = new WebClient ( ) ;
166
+ string xml = await wc . DownloadStringTaskAsync ( "http://codedead.com/Software/DeadLock/update.xml" ) ;
168
167
169
- XmlSerializer serializer = new XmlSerializer ( _update . GetType ( ) ) ;
170
- using ( MemoryStream stream = new MemoryStream ( ) )
171
- {
172
- StreamWriter writer = new StreamWriter ( stream ) ;
173
- writer . Write ( xml ) ;
174
- writer . Flush ( ) ;
175
- stream . Position = 0 ;
176
- _update = ( Update ) serializer . Deserialize ( stream ) ;
177
- writer . Dispose ( ) ;
178
- }
179
- if ( _update . CheckForUpdate ( ) )
168
+ XmlSerializer serializer = new XmlSerializer ( _update . GetType ( ) ) ;
169
+ using ( MemoryStream stream = new MemoryStream ( ) )
170
+ {
171
+ StreamWriter writer = new StreamWriter ( stream ) ;
172
+ writer . Write ( xml ) ;
173
+ writer . Flush ( ) ;
174
+ stream . Position = 0 ;
175
+ _update = ( Update ) serializer . Deserialize ( stream ) ;
176
+ writer . Dispose ( ) ;
177
+ }
178
+ if ( _update . CheckForUpdate ( ) )
179
+ {
180
+ if ( MessageBoxAdv . Show ( l . MsgVersion + " " + _update . GetUpdateVersion ( ) + " " + l . MsgAvailable + Environment . NewLine + l . MsgDownloadNewVersion , "DeadLock" , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) == DialogResult . Yes )
180
181
{
181
- if ( MessageBoxAdv . Show ( l . MsgVersion + " " + _update . GetUpdateVersion ( ) + " " + l . MsgAvailable + Environment . NewLine + l . MsgDownloadNewVersion , "DeadLock" , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) == DialogResult . Yes )
182
+ await Task . Run ( ( ) =>
182
183
{
183
184
new FrmUpdater ( _update , _languageManager . GetLanguage ( ) ) . ShowDialog ( ) ;
184
- }
185
- }
186
- else
187
- {
188
- if ( showNoUpdates )
189
- {
190
- MessageBoxAdv . Show ( l . MsgLatestVersionAlreadyInstalled , "DeadLock" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
191
- }
185
+ } ) ;
192
186
}
193
187
}
194
- catch ( Exception ex )
188
+ else
195
189
{
196
- if ( showError )
190
+ if ( showNoUpdates )
197
191
{
198
- MessageBoxAdv . Show ( ex . Message , "DeadLock" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
192
+ MessageBoxAdv . Show ( l . MsgLatestVersionAlreadyInstalled , "DeadLock" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
199
193
}
200
194
}
201
- } ) ;
195
+ }
196
+ catch ( Exception ex )
197
+ {
198
+ if ( showError )
199
+ {
200
+ MessageBoxAdv . Show ( ex . Message , "DeadLock" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
201
+ }
202
+ }
202
203
}
203
204
204
205
/// <summary>
0 commit comments