Fix cancellation of downloads.

The Download class cancels asynchronously, which means callers must handle cancellation inside the completion event, and not after requesting cancellation.
This commit is contained in:
RoosterDragon
2016-07-30 16:27:45 +01:00
parent 77d0a8c54e
commit 3b5798b5e8
6 changed files with 61 additions and 55 deletions

View File

@@ -128,11 +128,11 @@ namespace OpenRA
var url = Game.Settings.Game.MapRepository + "hash/" + string.Join(",", maps.Keys) + "/yaml";
Action<DownloadDataCompletedEventArgs, bool> onInfoComplete = (i, cancelled) =>
Action<DownloadDataCompletedEventArgs> onInfoComplete = i =>
{
if (cancelled || i.Error != null)
if (i.Error != null)
{
Log.Write("debug", "Remote map query failed with error: {0}", i.Error != null ? i.Error.Message : "cancelled");
Log.Write("debug", "Remote map query failed with error: {0}", Download.FormatErrorMessage(i.Error));
Log.Write("debug", "URL was: {0}", url);
foreach (var p in maps.Values)
p.UpdateRemoteSearch(MapStatus.Unavailable, null);