Exemplo n.º 1
0
        void Receive()
        {
            ReceiveThread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
            {
                while (true)
                {
                    System.Threading.WaitHandle.WaitAll(reset);
                    reset[0].Set();

                    if (SocketAsynPool.Count > 0)
                    {
                        SocketAsyncEventArgs sockasyn = SocketAsynPool.Pop();

                        if (BuffManagers.SetBuffer(sockasyn))
                        {
                            if (!Sock.ReceiveFromAsync(sockasyn))
                            {
                                BeginReceive(sockasyn);
                            }
                        }
                    }
                    else
                    {
                        reset[0].Reset();
                    }
                }
            }));

            ReceiveThread.Start();
        }