You have to use the AddressOf
operator:
Public Shared Function SendAsync(socket As Socket, buffer As Byte(), offset As Integer, count As Integer) As Task(Of Integer)
Return Task.Factory.FromAsync(...(...), AddressOf socket.EndSend)
End Function
Since you can omit the ()
when calling a method in VB.Net, the compiler does not know that you want to use socket.EndSend
as a delegate instead of calling it and thus expects it to return a Func(Of IAsyncResult, Integer)
, which it doesn't do. Hence the overload resolution error.