namespace Benchmark { using System; using System.Threading; using System.Threading.Tasks; using NodeHostEnvironment; public class Program { public static Task Main(string[] args) { var host = NodeHost.Instance; var tcs = new TaskCompletionSource(); host.Global.closeDotNet = new Action(() => tcs.SetResult(0)); var cbVoidToVoid = new Action(() => {}); host.Global.dotnetCallbacks.cbVoidToVoid = cbVoidToVoid; host.Global.dotnetCallbacks.cbIntIntToInt = new Func((a,b) => a + b); host.Global.dotnetCallbacks.cbIntIntToInt(0,0); host.Global.dotnetCallbacks.cbVoidToTask = new Func(() => Task.CompletedTask); host.Global.dotnetCallbacks.cbIntToTaskDelay = new Func(delay => Task.Delay(delay)); host.Global.dotnetCallbacks.cbIntToTaskDelayAsync = new Func(async delay => await Task.Delay(delay)); host.Global.dotnetCallbacks.cbVoidToTaskYield = new Func(async () => await Task.Yield()); host.Global.dotnetCallbacks.cbVoidToTaskYieldPromise = new Func(() => (Task)host.Global.Promise.resolve().then(new Action(() => {}))); host.Global.dotnetCallbacks.cbVoidToTaskYieldPromiseAsync = new Func(async () => await ((Task)host.Global.Promise.resolve())); host.Global.dotnetCallbacks.cbTaskToTask = new Func(async t => await t); host.Global.dotnetCallbacks.cbStringArrayToString = new Func(array => string.Join("|", array)); host.Global.dotnetCallbacks.cbStringToStringArray = new Func(s => s.Split('|')); return tcs.Task; } } }