From c19d41f3e64b080579a6d7c91a068dce85e6eae6 Mon Sep 17 00:00:00 2001 From: Daniel Mirmilshteyn Date: Sun, 17 Jul 2016 14:35:35 -0400 Subject: [PATCH] Added Task.FromResult --- .../Async/Classes/System.Threading.Tasks.Task.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/JSIL.Libraries/Includes/Bootstrap/Async/Classes/System.Threading.Tasks.Task.js b/JSIL.Libraries/Includes/Bootstrap/Async/Classes/System.Threading.Tasks.Task.js index 96ea6f83e..fde0e5ca7 100644 --- a/JSIL.Libraries/Includes/Bootstrap/Async/Classes/System.Threading.Tasks.Task.js +++ b/JSIL.Libraries/Includes/Bootstrap/Async/Classes/System.Threading.Tasks.Task.js @@ -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 ($) { @@ -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"), [], []) );