Example #1
0
        private string ExecuteHandler(
            IntPtr commandHandlerHandle, string json, string[] other, out string newSharedState)
        {
            _reverseCommandHandlerException = null;

            _prelude.ScheduleTerminateExecution();

            IntPtr resultJsonPtr;
            IntPtr result2JsonPtr;
            IntPtr memoryHandle;
            bool   success = Js1.ExecuteCommandHandler(
                _script.GetHandle(), commandHandlerHandle, json, other, other != null ? other.Length : 0,
                out resultJsonPtr, out result2JsonPtr, out memoryHandle);

            var terminated = _prelude.CancelTerminateExecution();

            if (!success)
            {
                CompiledScript.CheckResult(_script.GetHandle(), terminated, disposeScriptOnException: false);
            }
            string resultJson  = Marshal.PtrToStringUni(resultJsonPtr);
            string result2Json = Marshal.PtrToStringUni(result2JsonPtr);

            Js1.FreeResult(memoryHandle);
            if (_reverseCommandHandlerException != null)
            {
                throw new ApplicationException(
                          "An exception occurred while executing a reverse command handler. "
                          + _reverseCommandHandlerException.Message, _reverseCommandHandlerException);
            }
            newSharedState = result2Json;
            return(resultJson);
        }
Example #2
0
 public IntPtr GetHandle()
 {
     return(_script != null?_script.GetHandle() : IntPtr.Zero);
 }