private void SetAsyncOperationPools() { BufferManager = new PacketBufferManager(Settings.ReceiveOperationCount, Settings.SendOperationCount, Settings.BufferSize); for (int i = 0; i < ReceiveEventPool.Capacity; i++) { var args = new SocketAsyncEventArgs(); args.Completed += AsyncOperationCompleted; BufferManager.SetBuffer(args); PacketToken.Create(args); ReceiveEventPool.Push(args); } for (int i = 0; i < SendEventPool.Capacity; i++) { var args = new SocketAsyncEventArgs(); args.Completed += AsyncOperationCompleted; BufferManager.SetBuffer(args); PacketToken.Create(args); SendEventPool.Push(args); } }
private void SetAsyncOperationPools() { BufferManager = new PacketBufferManager(Settings.ReceiveOperationCount, Settings.SendOperationCount, Settings.BufferSize); for (int i = 0; i < ReceiveEventPool.Capacity; i++) { var args = new SocketAsyncEventArgs(); args.Completed += AsyncOperationCompleted; BufferManager.SetBuffer(args); PacketToken.Create(args); ReceiveEventPool.Push(args); } for (int i = 0; i < SendEventPool.Capacity; i++) { var args = new SocketAsyncEventArgs(); args.Completed += AsyncOperationCompleted; BufferManager.SetBuffer(args); PacketToken.Create(args); SendEventPool.Push(args); } }