Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Added Task.FromResult<TResult> #1007

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ JSIL.ImplementExternals("System.Threading.Tasks.Task", function ($) {
return tcs.Task;
}
);

$.Method({ Static: true, Public: true }, "FromResult",
(new JSIL.MethodSignature($jsilcore.TypeRef("System.Threading.Tasks.Task`1", ["!!0"]), ["!!0"], ["TResult"])),
function FromResult(TResult, result) {
var tcs = new (System.Threading.Tasks.TaskCompletionSource$b1.Of(TResult.__PublicInterface__))();
tcs.TrySetResult(result);
return tcs.Task;
}
);
});

JSIL.ImplementExternals("System.Threading.Tasks.Task`1", function ($) {
Expand Down Expand Up @@ -219,6 +228,10 @@ JSIL.MakeType({
new JSIL.MethodSignature($.Type, [$.Int32], [])
);

$.ExternalMethod({ Static: true, Public: true }, "FromResult",
new JSIL.MethodSignature($jsilcore.TypeRef("System.Threading.Tasks.Task`1", ["!!0"]), ["!!0"], ["TResult"])
);

$.ExternalMethod({ Static: false, Public: true }, "get_Exception",
new JSIL.MethodSignature($jsilcore.TypeRef("System.AggregateException"), [], [])
);
Expand Down