diff --git a/samples/111_clr_listener.js b/samples/111_clr_listener.js index 0624ac2f..6ec1bd32 100644 --- a/samples/111_clr_listener.js +++ b/samples/111_clr_listener.js @@ -15,8 +15,7 @@ var createController = edge.func(function () {/* { return new { yieldControl = (Func>)((i) => { - Startup.AcquireControl(); - return Startup.tcs.Task; + return Startup.AcquireControl(); }), regainControl = (Func>)(async (i) => { Startup.ReleaseControl(); @@ -25,7 +24,7 @@ var createController = edge.func(function () {/* }; } - static void AcquireControl() + static Task AcquireControl() { // single threaded; always called on V8 thread @@ -34,7 +33,9 @@ var createController = edge.func(function () {/* throw new InvalidOperationException("CLR already controls the lifetime of the process."); } - tcs = new TaskCompletionSource(); + TaskCompletionSource tmp = new TaskCompletionSource(); + tcs = tmp; + return tmp.Task; } public static void ReleaseControl()