代碼:
public async Task SendAsync(PacketReader reader) // .Net 4.5
改成
public void SendAsync(PacketReader reader) // 都可以
{
....
try
{
await this._socket.SendTaskAsync(buffer);
改成
this._socket.SendTaskAsync(buffer).Wait();
}
catch (Exception ex1)
{
....
return;
}
}
public async Task ReceiveAsync() // .Net 4.5
改成
public async Task ReceiveAsync() // 都可以
{
....
try
{
int taskAsync = await this._socket.ReceiveTaskAsync(receiveBuffer);
改成
this._socket.ReceiveTaskAsync(receiveBuffer).Wait();
}
catch (Exception ex)
{
....
return;
}
}