make sure iw4madmin exits when selecting "no" to continue with failed server connections
This commit is contained in:
parent
edf8e03b04
commit
58d48a211e
@ -66,8 +66,8 @@ namespace IW4MAdmin.Application.IO
|
||||
}
|
||||
return Task.FromResult(Enumerable.Empty<GameEvent>());
|
||||
}
|
||||
|
||||
new Thread(() => ReadNetworkData(client)).Start();
|
||||
|
||||
Task.Run(async () => await ReadNetworkData(client, _token), _token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -111,9 +111,9 @@ namespace IW4MAdmin.Application.IO
|
||||
return Task.FromResult((IEnumerable<GameEvent>)events);
|
||||
}
|
||||
|
||||
private void ReadNetworkData(UdpClient client)
|
||||
private async Task ReadNetworkData(UdpClient client, CancellationToken token)
|
||||
{
|
||||
while (!_token.IsCancellationRequested)
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
// get more data
|
||||
IPEndPoint remoteEndpoint = null;
|
||||
@ -127,7 +127,13 @@ namespace IW4MAdmin.Application.IO
|
||||
|
||||
try
|
||||
{
|
||||
bufferedData = client.Receive(ref remoteEndpoint);
|
||||
var result = await client.ReceiveAsync(_token);
|
||||
remoteEndpoint = result.RemoteEndPoint;
|
||||
bufferedData = result.Buffer;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.LogDebug("Stopping network log receive");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -153,6 +153,8 @@ namespace IW4MAdmin.Application
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
_serverManager?.Stop();
|
||||
|
||||
Console.WriteLine(exitMessage);
|
||||
await Console.In.ReadAsync(new char[1], 0, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user