Fix closure removal in Download.cs

This commit is contained in:
ScottNZ
2013-11-12 18:34:37 +13:00
parent 1394c1dcee
commit dfd19187fe

View File

@@ -21,7 +21,7 @@ namespace OpenRA
public static string FormatErrorMessage(Exception e) public static string FormatErrorMessage(Exception e)
{ {
var ex = e as System.Net.WebException; var ex = e as WebException;
if (ex == null) if (ex == null)
return e.Message; return e.Message;
@@ -46,15 +46,15 @@ namespace OpenRA
wc.DownloadProgressChanged += (_, a) => onProgress(a); wc.DownloadProgressChanged += (_, a) => onProgress(a);
wc.DownloadFileCompleted += (_, a) => onComplete(a, cancelled); wc.DownloadFileCompleted += (_, a) => onComplete(a, cancelled);
Game.OnQuit += () => Cancel(); Game.OnQuit += Cancel;
wc.DownloadFileCompleted += (_, a) => { Game.OnQuit -= () => Cancel(); }; wc.DownloadFileCompleted += (_, a) => { Game.OnQuit -= Cancel; };
wc.DownloadFileAsync(new Uri(url), path); wc.DownloadFileAsync(new Uri(url), path);
} }
public void Cancel() public void Cancel()
{ {
Game.OnQuit -= () => Cancel(); Game.OnQuit -= Cancel;
wc.CancelAsync(); wc.CancelAsync();
cancelled = true; cancelled = true;
} }