Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ public override bool Execute ()

assemblyMap.Load (AssemblyIdentityMapFile);

ThreadingTasks.Parallel.ForEach (ManifestFiles, () => 0, DoExecute, (obj) => { Complete (); });
ThreadingTasks.ParallelOptions options = new ThreadingTasks.ParallelOptions {
CancellationToken = Token,
TaskScheduler = ThreadingTasks.TaskScheduler.Current,
};

ThreadingTasks.Parallel.ForEach (ManifestFiles, options, () => 0, DoExecute, (obj) => { Complete (); });

base.Execute ();

Expand Down
5 changes: 3 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ bool DoExecute () {

var task = ThreadingTasks.Task.Run ( () => {
return RunParallelAotCompiler (nativeLibs);
});
}, Token);

task.ContinueWith ( (t) => {
Complete ();
});
}).ConfigureAwait (false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure ConfigureAwait(false) does anything unless you are awaiting it. I think it only controls the code after an await statement.

I think you need to passing the options to an overload of ContinueWith: https://msdn.microsoft.com/en-us/library/dd321561(v=vs.110).aspx

Probably not a way to write a unit test for this to know if it's for sure correct...


base.Execute ();

Expand All @@ -267,6 +267,7 @@ bool RunParallelAotCompiler (List<string> nativeLibs)

ThreadingTasks.ParallelOptions options = new ThreadingTasks.ParallelOptions {
CancellationToken = cts.Token,
TaskScheduler = ThreadingTasks.TaskScheduler.Current,
};

ThreadingTasks.Parallel.ForEach (GetAotConfigs (), options,
Expand Down
7 changes: 6 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Crunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ public override bool Execute ()
if (!imageFiles.Any ())
return true;

ThreadingTasks.ParallelOptions options = new ThreadingTasks.ParallelOptions {
CancellationToken = Token,
TaskScheduler = ThreadingTasks.TaskScheduler.Current,
};

var imageGroups = imageFiles.GroupBy (x => Path.GetDirectoryName (Path.GetFullPath (x.ItemSpec)));

ThreadingTasks.Parallel.ForEach (imageGroups, () => 0, DoExecute, (obj) => { Complete (); });
ThreadingTasks.Parallel.ForEach (imageGroups, options, () => 0, DoExecute, (obj) => { Complete (); });

return !Log.HasLoggedErrors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,13 @@ public override bool Execute ()
}
}
}
}).ContinueWith ((t) => {
if (t.Exception != null)
Log.LogErrorFromException (t.Exception.GetBaseException ());
}, Token).ContinueWith ((t) => {
if (t.Exception != null) {
var ex = t.Exception.GetBaseException ();
LogError (ex.Message + Environment.NewLine + ex.StackTrace);
}
Complete ();
});
}).ConfigureAwait (false);

var result = base.Execute ();

Expand Down