示例#1
0
        public bool SessionMessage(Who sender, Message msg)
        {
            XType type = msg.GetXType;

            StubHelperRun helper = (StubHelperRun)type.GetStubHelper();

            if (helper == null)
            {
                return(false);
            }

            switch (type.GetAsyncMode())
            {
            case AsyncMode.QUEUED:
                try
                {
                    _queued.Run(
                        delegate { helper(_src, _obj, sender, msg); },
                        delegate(Exception e) { SessionNotify(_obj, e); });
                }
                catch (Exception e)
                {
                    SessionNotify(_obj, e);
                }
                break;

            case AsyncMode.FREE:
                try
                {
                    _free.Run(
                        delegate { helper(_src, _obj, sender, msg); },
                        delegate(Exception e) { SessionNotify(_obj, e); });
                }
                catch (Exception e)
                {
                    SessionNotify(_obj, e);
                }
                break;

            case AsyncMode.NONE:
                try
                {
                    helper(_src, _obj, sender, msg);
                }
                catch (Exception e)
                {
                    SessionNotify(_obj, e);
                }
                break;

            default:
                throw new ArgumentException("unknown async mode " + type.GetAsyncMode());
            }

            return(true);
        }