private void CreateMessagePipeline(PipelineManualResetEventSlim slim, long bagid)
        {
            new Action(() =>
            {
                try
                {
                    slim.Reset();
                    slim.Wait(30000);

                    if (!slim.IsTimeOut)
                    {
                        var message = EntityBufCore.DeSerialize <Message>(slim.MsgBuffer);
                        DispatchMessage(message);
                    }
                    else
                    {
                        Console.Write("接收超时:" + bagid);
                        OnError(new TimeoutException("接收超时"));
                    }
                }
                finally
                {
                    ClearTempBag(bagid, null);
                    _pipelineSlimDic.Remove(bagid);
                }
            }).BeginInvoke(null, null);
        }
Exemple #2
0
        private void CreateMessagePipeline(IPEndPoint endpoint, PipelineManualResetEventSlim slim, long bagid, string pipelinekey)
        {
            new Action(() =>
            {
                int trytimes = 0;
                try
                {
                    while (true)
                    {
                        slim.Reset();
                        slim.Wait(30000);

                        if (!slim.IsTimeOut)
                        {
                            var message = LJC.FrameWork.EntityBuf.EntityBufCore.DeSerialize <Message>(slim.MsgBuffer);
                            DispatchMessage(message, endpoint);
                            break;
                        }
                        else
                        {
                            trytimes++;
                            if (trytimes >= TimeOutTryTimes)
                            {
                                throw new TimeoutException();
                            }
                        }
                    }
                }
                finally
                {
                    _pipelineSlimDic.Remove(pipelinekey);
                    ClearTempBag(bagid, endpoint);
                }
            }).BeginInvoke(null, null);
        }