Beispiel #1
0
        private void ExecutionThreadEntry(RemoteConnection connection)
        {
            if (returnImmediately)
            {
                // only happens in calls from the browser to the renderer
                CfxDebug.Assert(connection == RemoteClient.connection);
                ExecuteInTargetProcess(connection);
                return;
            }

            if (RemoteClient.connection == null)
            {
                if (!CfxRemoteCallbackManager.IncrementCallbackCount(connection.remoteProcessId))
                {
                    // The application has suspended remote callbacks.
                    // Write the response without ececuting event handlers, returning default values.
                    connection.EnqueueWrite(WriteResponse);
                    return;
                }
            }

            var threadContext = new CfxRemoteCallContext(connection, remoteThreadId);

            threadContext.Enter();
            var threadStackCount = CfxRemoteCallContext.ContextStackCount;

            try {
                ExecuteInTargetProcess(connection);
            } finally {
                if (RemoteClient.connection == null)
                {
                    CfxRemoteCallbackManager.DecrementCallbackCount(connection.remoteProcessId);
                }
                if (threadStackCount != CfxRemoteCallContext.ContextStackCount || CfxRemoteCallContext.CurrentContext != threadContext)
                {
                    CfxRemoteCallContext.resetStack(threadStackCount - 1);
                    throw new CfxException("Unbalanced remote call context stack. Make sure to balance calls to CfxRemoteCallContext.Enter() and CfxRemoteCallContext.Exit() in all render process callback events.");
                }
                threadContext.Exit();
            }

            connection.EnqueueWrite(WriteResponse);
        }
Beispiel #2
0
        /// <summary>
        /// Prepares and executes the remote procedure in the remote process
        /// </summary>
        internal void Execute(RemoteConnection connection)
        {
            if (returnImmediately)
            {
                RemoteProcedure();
                return;
            }

            if (RemoteClient.connection == null)
            {
                if (!CfxRemoteCallbackManager.IncrementCallbackCount(connection.remoteProcessId))
                {
                    // The application has suspended remote callbacks.
                    // Return without ececuting event handlers, connection will return default values.
                    return;
                }
            }

            var threadContext = new CfxRemoteCallContext(connection, remoteThreadId);

            threadContext.Enter();
            var threadStackCount = CfxRemoteCallContext.ContextStackCount;

            try {
                RemoteProcedure();
            } finally {
                if (RemoteClient.connection == null)
                {
                    CfxRemoteCallbackManager.DecrementCallbackCount(connection.remoteProcessId);
                }
                if (threadStackCount != CfxRemoteCallContext.ContextStackCount || CfxRemoteCallContext.CurrentContext != threadContext)
                {
                    CfxRemoteCallContext.resetStack(threadStackCount - 1);
                    throw new CfxException("Unbalanced remote call context stack. Make sure to balance calls to CfxRemoteCallContext.Enter() and CfxRemoteCallContext.Exit() in all render process callback events.");
                }
                threadContext.Exit();
            }
        }