Skip to content

Commit b80b51a

Browse files
committed
Fixed local sync issue
1 parent 30b0ecb commit b80b51a

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

DeadLock/Forms/FrmMain.cs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -166,46 +166,47 @@ private void LanguageSwitch()
166166
private async void Update(bool showError, bool showNoUpdates)
167167
{
168168
Language l = _languageManager.GetLanguage();
169-
await Task.Run(() =>
169+
170+
try
170171
{
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");
175174

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)
187188
{
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(() =>
189190
{
190191
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+
});
199193
}
200194
}
201-
catch (Exception ex)
195+
else
202196
{
203-
if (showError)
197+
if (showNoUpdates)
204198
{
205-
MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
199+
MessageBoxAdv.Show(l.MsgLatestVersionAlreadyInstalled, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Information);
206200
}
207201
}
208-
});
202+
}
203+
catch (Exception ex)
204+
{
205+
if (showError)
206+
{
207+
MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
208+
}
209+
}
209210
}
210211

211212
/// <summary>

0 commit comments

Comments
 (0)