コード例 #1
0
        private static void ConsumeMethod(object prodConsObj)
        {
            ProducerConsumerInterlocked <DTO> prodCons = prodConsObj as ProducerConsumerInterlocked <DTO>;
            DTO dto;

            if (prodCons == null)
            {
                bKillSwitch = true;
            }

            while (!bKillSwitch)
            {
                dto = prodCons.Dequeue();
                cTimer.RecordTime(cTimer.ActionsEnm.Deq, dto.uiData2);
            }
        }
コード例 #2
0
        public static IProduceConsume <T> GetImplementation(ProdCons enmType, int capacity)
        {
            IProduceConsume <T> interfaceToReturn;

            switch (enmType)
            {
            case ProdCons.Interlocked:
                interfaceToReturn = new ProducerConsumerInterlocked <T>();
                interfaceToReturn.Init(capacity);
                break;

            case ProdCons.ConcurQue:
                interfaceToReturn = new ConcurrQueProdCons <T>();
                interfaceToReturn.Init(capacity);
                break;

            default:
                interfaceToReturn = null;
                break;
            }

            return(interfaceToReturn);
        }