Beispiel #1
0
 public static void ReturnProtocolThreadSafe(Protocol protocol)
 {
     if (RegisterProtocolFactory != null && protocol != null)
     {
         lock (RegisterProtocolFactory)
         {
             ProtocalFactory factory = null;
             if (RegisterProtocolFactory.TryGetValue(protocol.GetMessageID(), out factory))
             {
                 factory.Return(protocol);
             }
         }
     }
 }
Beispiel #2
0
        public static Protocol GetProtocolThreadSafe(int type)
        {
            Protocol protocol = null;

            lock (RegisterProtocolFactory)
            {
                ProtocalFactory factory = null;
                if (RegisterProtocolFactory.TryGetValue(type, out factory))
                {
                    protocol = factory.Get();
                }
            }
            return(protocol);
        }