System.Runtime.Remoting.Contexts.Context.DoCallBackGeneric C# (CSharp) Méthode

DoCallBackGeneric() private méthode

private DoCallBackGeneric ( IntPtr targetCtxID, CrossContextDelegate deleg ) : void
targetCtxID IntPtr
deleg CrossContextDelegate
Résultat void
        internal void DoCallBackGeneric(
            IntPtr targetCtxID, CrossContextDelegate deleg)
        {               
            TransitionCall msgCall = new TransitionCall(targetCtxID, deleg);           
            
            Message.PropagateCallContextFromThreadToMessage(msgCall);
            //DBG Console.WriteLine("CallBackGeneric starting!");
            IMessage retMsg = this.GetClientContextChain().SyncProcessMessage(msgCall); 
            if (null != retMsg)
            {
                Message.PropagateCallContextFromMessageToThread(retMsg);
            }
            
            IMethodReturnMessage msg = retMsg as IMethodReturnMessage;
            if (null != msg)
            {
                if (msg.Exception != null)
                    throw msg.Exception;
            }
            //DBG Console.WriteLine("CallBackGeneric finished!");
        }
        

Usage Example

        public void DoCallBack(CrossContextDelegate deleg)
        {
            /*DBG Console.WriteLine("public DoCallBack: targetCtx: "
             + Int32.Format(this.InternalContextID,"x")); DBG*/

            if (deleg == null)
            {
                throw new ArgumentNullException("deleg");
            }

            if ((_ctxFlags & CTX_FROZEN) == 0)
            {
                throw new RemotingException(
                          Environment.GetResourceString(
                              "Remoting_Contexts_ContextNotFrozenForCallBack"));
            }

            Context currCtx = Thread.CurrentContext;

            if (currCtx == this)
            {
                // We are already in the target context, just execute deleg
                // NOTE: If in the future we decide to leave the context
                // and reenter it for this case we will need to change
                // Context::RequestCallBack method in VM also!
                deleg();
            }
            else
            {
                // We pass 0 for target domain ID for x-context case.
                currCtx.DoCallBackGeneric(this.InternalContextID, deleg);
                GC.KeepAlive(this);
            }
        }
All Usage Examples Of System.Runtime.Remoting.Contexts.Context::DoCallBackGeneric