我有一个返回任务的方法,如:
public static Task<int> SendAsync(this Socket socket, byte[] buffer, int offset, int count)
{
if (socket == null) throw new ArgumentNullException("socket");
if (buffer == null) throw new ArgumentNullException("buffer");
return Task.Factory.FromAsync<int>(
socket.BeginSend(buffer, offset, count, SocketFlags.None, null, socket),
socket.EndSend);
}
Run Code Online (Sandbox Code Playgroud)
我想保留对该任务的引用并稍后运行它.但是,似乎由FromAsync方法创建的任务立即执行.我怎样才能推迟执行?