public static void NodejsFuncComplete(IntPtr context, int taskStatus, IntPtr result, int resultType) { CoreCLREmbedding.DebugMessage("NodejsFuncInvokeContext::NodejsFuncComplete (CLR) - Starting"); GCHandle gcHandle = GCHandle.FromIntPtr(context); NodejsFuncInvokeContext actualContext = (NodejsFuncInvokeContext)gcHandle.Target; gcHandle.Free(); V8Type v8ResultType = (V8Type)resultType; object marshalledResult = CoreCLREmbedding.MarshalV8ToCLR(result, v8ResultType); CoreCLREmbedding.DebugMessage("NodejsFuncInvokeContext::NodejsFuncComplete (CLR) - Marshalled result data back to the CLR"); if (taskStatus == (int)TaskStatus.Faulted) { actualContext.TaskCompletionSource.SetException((Exception)marshalledResult); CoreCLREmbedding.DebugMessage("NodejsFuncInvokeContext::NodejsFuncComplete (CLR) - Set the exception received from Node.js: {0}", ((Exception)marshalledResult).Message); } else { actualContext.TaskCompletionSource.SetResult(marshalledResult); CoreCLREmbedding.DebugMessage("NodejsFuncInvokeContext::NodejsFuncComplete (CLR) - Set result data"); } CoreCLREmbedding.DebugMessage("NodejsFuncInvokeContext::NodejsFuncComplete (CLR) - Finished"); }
Task<object> FunctionWrapper(object payload) { NodejsFuncInvokeContext ctx = new NodejsFuncInvokeContext(this, payload); ExecuteActionOnV8Thread(ctx.CallFuncOnV8Thread); return ctx.TaskCompletionSource.Task; }
Task <object> FunctionWrapper(object payload) { NodejsFuncInvokeContext ctx = new NodejsFuncInvokeContext(this, payload); ExecuteActionOnV8Thread(ctx.CallFuncOnV8Thread); return(ctx.TaskCompletionSource.Task); }
private Task<object> FunctionWrapper(object payload) { CoreCLREmbedding.DebugMessage("NodejsFunc::FunctionWrapper (CLR) - Started"); NodejsFuncInvokeContext invokeContext = new NodejsFuncInvokeContext(this, payload); invokeContext.CallFunc(); CoreCLREmbedding.DebugMessage("NodejsFunc::FunctionWrapper (CLR) - Node.js function invoked on the V8 thread, returning the task completion source"); return invokeContext.TaskCompletionSource.Task; }
private Task <object> FunctionWrapper(object payload) { CoreCLREmbedding.DebugMessage("NodejsFunc::FunctionWrapper (CLR) - Started"); NodejsFuncInvokeContext invokeContext = new NodejsFuncInvokeContext(this, payload); invokeContext.CallFunc(); CoreCLREmbedding.DebugMessage("NodejsFunc::FunctionWrapper (CLR) - Node.js function invoked on the V8 thread, returning the task completion source"); return(invokeContext.TaskCompletionSource.Task); }
static extern void CallFuncOnV8ThreadInternal(NodejsFuncInvokeContext _this, IntPtr nativeNodejsFunc, object payload);