Ejemplo n.º 1
0
        [System.Security.SecurityCritical]  // auto-generated
        public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink)
        {
            IMessageCtrl msgCtrl = null;

            Contract.Assert(_property.Locked == true, "_property.Locked == true");

            if (!_property.IsReEntrant)
            {
                // In this case new calls are not allowed to enter the domain
                // We need to track potentially more than one async-call-outs
                // and allow the completion notifications to come in for those

                LogicalCallContext cctx =
                    (LogicalCallContext)reqMsg.Properties[Message.CallContextKey];
                // We used to generate a new lcid automatically in RemotingProxy
                // Invoke at the start of each Async call.
                // However now we do it here as an optimization (since only
                // Synchronization needs it)
                // RemotingProxy invoke code does Clone() the callContext at
                // the start of each Async call so we don't have to worry
                // about stomping someone else's lcid here.


                String lcid = Identity.GetNewLogicalCallID();
                cctx.RemotingData.LogicalCallID = lcid;


                Contract.Assert(
                    _property.SyncCallOutLCID == null,
                    "Cannot handle async call outs when already in a top-level sync call out");
                //DBGConsole.WriteLine(Thread.CurrentThread.GetHashCode()+"] NR: Async CallOut: adding to lcidList: " + lcid);
                _property.AsyncCallOutLCIDList.Add(lcid);
            }
            // We will call AsyncProcessMessage directly on this thread
            // since the thread should not block much. However, we will
            // have to intercept the callback on the replySink chain for
            // which we wrap the caller provided replySink into our sink.
            AsyncReplySink mySink = new AsyncReplySink(replySink, _property);

            // NOTE: we will need to yield the Synchronization Domain at
            // some time or another to get our own callBack to complete.

            // Note that for the Async call-outs we have to provide an interception
            // sink whether we are re-entrant or not since we want
            // the replySink.SyncProcessMessage call to be wait for the lock just like
            // any other call-in.
            //DBGConsole.WriteLine(Thread.CurrentThread.GetHashCode()+"] Async call-out");

            msgCtrl = _nextSink.AsyncProcessMessage(reqMsg, (IMessageSink)mySink);
            //DBGConsole.WriteLine(Thread.CurrentThread.GetHashCode()+"] Async call-out AsyncPM returned, reply to come separately");

            return(msgCtrl);
        }
        public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink)
        {
            if (!this._property.IsReEntrant)
            {
                LogicalCallContext context          = (LogicalCallContext)reqMsg.Properties[Message.CallContextKey];
                string             newLogicalCallID = Identity.GetNewLogicalCallID();
                context.RemotingData.LogicalCallID = newLogicalCallID;
                this._property.AsyncCallOutLCIDList.Add(newLogicalCallID);
            }
            AsyncReplySink sink = new AsyncReplySink(replySink, this._property);

            return(this._nextSink.AsyncProcessMessage(reqMsg, sink));
        }