捕获OperationAborted异常
This commit is contained in:
parent
a7304ea5e0
commit
0876c6b35d
@ -126,12 +126,19 @@ namespace FastGithub.Dns
|
||||
{
|
||||
var remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
|
||||
while (stoppingToken.IsCancellationRequested == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await this.socket.ReceiveFromAsync(this.buffer, SocketFlags.None, remoteEndPoint);
|
||||
var datas = new byte[result.ReceivedBytes];
|
||||
this.buffer.AsSpan(0, datas.Length).CopyTo(datas);
|
||||
this.HandleRequestAsync(datas, result.RemoteEndPoint, stoppingToken);
|
||||
}
|
||||
catch (SocketException ex) when (ex.SocketErrorCode == SocketError.OperationAborted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user