private ResultCacheManager GetCache(IBehaviorContext context)
        {
            ResultCacheManager c;

            if (!_cache.TryGet(context, out c))
            {
                c = new ResultCacheManager();
                _cache.Set(context, c);
            }

            return(c);
        }
        /// <summary>
        /// 初始化
        /// </summary>
        public ServiceMainForm()
        {
            InitializeComponent();
            //初始化接收请求队列
            m_ReceiveCommandCaches = new ResultCacheManager <ServiceCommand>();

            // 初始化通信控制类
            m_CommunicationControl = new MSMQServer();
            m_CommunicationControl.MessageReceived += CommunicationControl_MessageReceived;

            // 发送处理结果
            Thread thread = new Thread(new ThreadStart(DealResult));

            thread.IsBackground = true;
            thread.Start();
        }
Beispiel #3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public CommunicationControl()
        {
            try
            {
                m_HostId = Guid.NewGuid().ToString();

                m_SendQueue    = new ConcurrentQueue <ServiceCommand>();
                m_ReceiveQueue = new ConcurrentQueue <ServiceCommand>();

                m_CommunicationForm = new CommunicationForm(m_HostId);
                m_CommunicationForm.MessageReceived += new MessageReceivedHandler(Received);

                // 初始化发送缓存
                m_SendCommandCaches = new ResultCacheManager <ServiceCommand>();
                // 结果缓存
                m_ReceiveCommandCaches = new ResultCacheManager <ServiceCommand>();

                m_IsSend     = true;
                m_IsReceived = true;

                Thread tdSend = new Thread(new ThreadStart(QueueSend));
                tdSend.IsBackground = true;
                tdSend.Start();
                tdSend = null;
            }
            catch (Exception ex)
            {
                m_Logger.Error("初始化CommunicationControl" + ex.Message);
                m_Logger.Error("初始化CommunicationControl" + ex.StackTrace);
            }

            //Thread tdReceive = new Thread(new ThreadStart(QueueReceive));
            //tdReceive.IsBackground = true;
            //tdReceive.Start();
            //tdReceive = null;
        }
        /// <summary>
        /// 初始化
        /// </summary>
        public NamedPipeServer()
        {
            m_PipeServer = new NamedPipeServerStream(m_NamedPipeName, PipeDirection.InOut, 20);

            // 初始化队列
            m_SendQueue = new ConcurrentQueue <ServiceCommand>();
            //m_ReceiveQueue = new ConcurrentQueue<ServiceCommand>();
            // 结果缓存
            m_ReceiveCommandCaches = new ResultCacheManager <ServiceCommand>();

            // 发送进程
            //Thread threadSend = new Thread(new ThreadStart(QueueSend));
            //threadSend.IsBackground = true;
            //threadSend.Start();

            // 接收进程
            Thread threadReceive = new Thread(new ThreadStart(QueueReceive));

            threadReceive.IsBackground = true;
            threadReceive.Start();

            m_IsSend     = true;
            m_IsReceived = true;
        }