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