socketsasynchronousilistbufferingbeginreceive

Is Socket.BeginReceive(IList<ArraySegment<byte>> buffers.. Not Asynchronous?


I have been looking to implement a custom class of :

IList<ArraySegment<byte>>

this will be passed to a socket, and used as the buffer to receive data from that Socket.

Socket.BeginReceive(
    IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object
    )

MSDN Documentation

While testing I have found that when calling

BeginReceive(IList..

It blocks?! When replacing this with the BeginReceive(byte[]... is acts asynchronously.

Has anyone else come accross this?

I will post my testing code up if required but would like to hear from anyone out there before I uglify this question :)

Thanks!


Solution

  • So! I found out the issue.

    As I had a

    Console.WriteLine
    

    present in my custom

    IList<ArraySegment<byte>>
    

    then the method was not acting asynchronously on compile :)