0
我想在VB.NET中編寫C#中的Task.Factory.FromAsync實現。VB.NET中的Task.Factory.FromAsync語法
這是C#語法。
public static Task<int> SendAsync(this Socket socket, byte[] buffer, int offset, int count)
{
return Task.Factory.FromAsync<int>(
socket.BeginSend(buffer, offset, count, SocketFlags.None, null, socket),
socket.EndSend);
}
我把它轉換成在VB.NET
以下Public Shared Function SendAsync(socket As Socket, buffer As Byte(), offset As Integer, count As Integer) As Task(Of Integer)
Return Task.Factory.FromAsync(Of Integer)(socket.BeginSend(buffer, offset, count, SocketFlags.None, Nothing, socket), socket.EndSend)
End Function
然而,在VB.NET語法,我碰到下面的錯誤。此代碼在C#中完美工作。
Overload resolution failed because no accessible 'EndSend' accepts this number of arguments.
我錯過了什麼嗎?
工作正常!謝謝 :) – Dhiru