From 96c2647193387caa939a241935ff3418f62083ab Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Sat, 24 Oct 2020 04:38:14 +0200 Subject: [PATCH] Use LongRunning tasks for the server and client --- src/Impostor.Hazel/Udp/UdpClientConnection.cs | 2 +- src/Impostor.Hazel/Udp/UdpConnection.cs | 2 +- src/Impostor.Hazel/Udp/UdpConnectionListener.cs | 2 +- src/Impostor.Tools.ServerReplay/Program.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Impostor.Hazel/Udp/UdpClientConnection.cs b/src/Impostor.Hazel/Udp/UdpClientConnection.cs index f163e5b..4f81177 100644 --- a/src/Impostor.Hazel/Udp/UdpClientConnection.cs +++ b/src/Impostor.Hazel/Udp/UdpClientConnection.cs @@ -114,7 +114,7 @@ namespace Impostor.Hazel.Udp try { - _listenTask = ListenAsync(); + _listenTask = Task.Factory.StartNew(ListenAsync, TaskCreationOptions.LongRunning); } catch (ObjectDisposedException) { diff --git a/src/Impostor.Hazel/Udp/UdpConnection.cs b/src/Impostor.Hazel/Udp/UdpConnection.cs index 7227dba..fbd74b7 100644 --- a/src/Impostor.Hazel/Udp/UdpConnection.cs +++ b/src/Impostor.Hazel/Udp/UdpConnection.cs @@ -40,7 +40,7 @@ namespace Impostor.Hazel.Udp public Task StartAsync() { // Store the task we're executing - _executingTask = ReadAsync(); + _executingTask = Task.Factory.StartNew(ReadAsync, TaskCreationOptions.LongRunning); // If the task is completed then return it, this will bubble cancellation and failure to the caller if (_executingTask.IsCompleted) diff --git a/src/Impostor.Hazel/Udp/UdpConnectionListener.cs b/src/Impostor.Hazel/Udp/UdpConnectionListener.cs index a2b6180..f00f98f 100644 --- a/src/Impostor.Hazel/Udp/UdpConnectionListener.cs +++ b/src/Impostor.Hazel/Udp/UdpConnectionListener.cs @@ -84,7 +84,7 @@ namespace Impostor.Hazel.Udp public override Task StartAsync() { // Store the task we're executing - _executingTask = ListenAsync(); + _executingTask = Task.Factory.StartNew(ListenAsync, TaskCreationOptions.LongRunning); // If the task is completed then return it, this will bubble cancellation and failure to the caller if (_executingTask.IsCompleted) diff --git a/src/Impostor.Tools.ServerReplay/Program.cs b/src/Impostor.Tools.ServerReplay/Program.cs index 424a7bf..8ae8bfa 100644 --- a/src/Impostor.Tools.ServerReplay/Program.cs +++ b/src/Impostor.Tools.ServerReplay/Program.cs @@ -125,7 +125,7 @@ namespace Impostor.Tools.ServerReplay var addressLength = reader.ReadByte(); var addressBytes = reader.ReadBytes(addressLength); var addressPort = reader.ReadUInt16(); - var address = new IPEndPoint(new IPAddress(addressBytes), clientId); + var address = new IPEndPoint(new IPAddress(addressBytes), addressPort); var name = reader.ReadString(); // Create and register connection. -- 2.39.5