diff --git a/Server/AuthSession.cs b/Server/AuthSession.cs index 9a591b7..ae0227a 100644 --- a/Server/AuthSession.cs +++ b/Server/AuthSession.cs @@ -81,7 +81,7 @@ public class AuthSession : TcpSession RawPacket rawPacket = new RawPacket((OperationCode)opCode, dataBuffer, clientAliveTime, buffer[0], buffer[3], Id, this); - Parallel.Invoke(() => _mediator.Send(rawPacket)); + Task.Run(() => _mediator.Send(rawPacket)); _logger.LogInformation("Connection from: {@RemoteEndpoint}", Socket.RemoteEndPoint?.ToString()); base.OnReceived(decryptedBuffer.ToArray(), offset, decryptedBuffer.Length); } diff --git a/Server/Services/PacketDistributorService.cs b/Server/Services/PacketDistributorService.cs index 0543a8c..a154bf0 100644 --- a/Server/Services/PacketDistributorService.cs +++ b/Server/Services/PacketDistributorService.cs @@ -77,17 +77,17 @@ public class PacketDistributorService : IHostedService public void AddPacket(RawPacket rawPacket) { + _concurrentQueue.Enqueue(rawPacket); + Task.Run(() => DequeueAndProcessAsync()); _logger.LogInformation("Packet with ID: {MessageOperationCode} has been received", rawPacket.OperationCode); - _concurrentQueue.Enqueue(rawPacket); - Parallel.Invoke(() => DequeueAndProcessAsync()); } private async Task DequeueAndProcessAsync() { if (_concurrentQueue.TryDequeue(out var item)) { - Parallel.Invoke(() => + Task.Run(() => { _logger.LogTrace("[{TempId}] Packet with ID: {MessageOperationCode} is being dequeued", item.Session.Id, item.OperationCode);