Ejemplo n.º 1
0
 internal MsgSender(MsgReceiver receiver)
 {
     Receiver = receiver;
     System.Diagnostics.StackTrace   st = new System.Diagnostics.StackTrace();
     System.Diagnostics.StackFrame[] fs = st.GetFrames();
     foreach (System.Diagnostics.StackFrame f in fs)
     {
         Type tp = f.GetMethod().DeclaringType;
         if (tp == typeof(MsgSender) || tp == typeof(MsgQueue))
         {
             continue;
         }
         AskClassName = "{" + tp.FullName + "}";
         break;
         //if (st.FrameCount > 1)
         //    dllname = st.GetFrame(1).GetMethod().DeclaringType.Namespace.ToUpper();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 注册本地消息接收端
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static MsgReceiver RegisterReceiver(string name)
        {
            if (name == null)
            {
                return(null);
            }
            name = name.ToUpper().Trim();
            if (name == "")
            {
                return(null);
            }
            sMutex.WaitOne();
            MsgReceiver r = _RegisterReceiver(name, 2);

            if (r != null)
            {
                r.bRegistered = true;
            }
            sMutex.ReleaseMutex();
            return(r);
        }
Ejemplo n.º 3
0
        static MsgReceiver _RegisterReceiver(string name, int remotemode)
        {
            MsgReceiver r = null;

            foreach (MsgReceiver mr in Receivers)
            {
                if (mr.Name == name)
                {
                    if (mr.bRegistered)
                    {
                        return(null);
                    }
                    r = mr;
                    break;
                }
            }
            if (r == null)
            {
                r = new MsgReceiver(name);
                Receivers.Add(r);
            }
            return(r);
        }