예제 #1
0
 public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
 {
                 #if !DISABLE_REMOTING
     ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);
     return(identity.AsyncObjectProcessMessage(msg, replySink));
                 #else
     return(null);
                         #endif
 }
예제 #2
0
        public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
                        #if !DISABLE_REMOTING
            ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);

            Context oldContext = null;
            if (Threading.Thread.CurrentContext != identity.Context)
            {
                oldContext = Context.SwitchToContext(identity.Context);
            }

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, true);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);
                if (replySink != null)
                {
                    replySink = new ContextRestoreSink(replySink, oldContext, msg);
                }

                IMessageCtrl res = identity.AsyncObjectProcessMessage(msg, replySink);

                if (replySink == null)
                {
                    Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                    Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
                }

                return(res);
            }
            catch (Exception ex)
            {
                if (replySink != null)
                {
                    replySink.SyncProcessMessage(new ReturnMessage(ex, (IMethodCallMessage)msg));
                }
                return(null);
            }
            finally
            {
                if (oldContext != null)
                {
                    Context.SwitchToContext(oldContext);
                }
            }
                        #else
            return(null);
                        #endif
        }
        public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
            ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);
            Context        context        = null;

            if (Thread.CurrentContext != serverIdentity.Context)
            {
                context = Context.SwitchToContext(serverIdentity.Context);
            }
            IMessageCtrl result;

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, true);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);
                if (replySink != null)
                {
                    replySink = new CrossContextChannel.ContextRestoreSink(replySink, context, msg);
                }
                IMessageCtrl messageCtrl = serverIdentity.AsyncObjectProcessMessage(msg, replySink);
                if (replySink == null)
                {
                    Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                    Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
                }
                result = messageCtrl;
            }
            catch (Exception e)
            {
                if (replySink != null)
                {
                    replySink.SyncProcessMessage(new ReturnMessage(e, (IMethodCallMessage)msg));
                }
                result = null;
            }
            finally
            {
                if (context != null)
                {
                    Context.SwitchToContext(context);
                }
            }
            return(result);
        }
예제 #4
0
        public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
            ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);

            return(serverIdentity.AsyncObjectProcessMessage(msg, replySink));
        }