From a476feec3697ae2ce9b3ab6d405de16d03073420 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 14 Aug 2024 08:11:25 +0200 Subject: [PATCH] Shutdown CT for IPC --- ShockOsc/Services/Pipes/PipeServerService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ShockOsc/Services/Pipes/PipeServerService.cs b/ShockOsc/Services/Pipes/PipeServerService.cs index eae0192..7fac24e 100644 --- a/ShockOsc/Services/Pipes/PipeServerService.cs +++ b/ShockOsc/Services/Pipes/PipeServerService.cs @@ -1,7 +1,5 @@ -using System.Collections.Concurrent; -using System.IO.Pipes; +using System.IO.Pipes; using System.Text.Json; -using Microsoft.Extensions.Logging; using OpenShock.SDK.CSharp.Utils; using OpenShock.ShockOsc.Utils; @@ -10,11 +8,13 @@ namespace OpenShock.ShockOsc.Services.Pipes; public sealed class PipeServerService { private readonly ILogger _logger; + private readonly IHostApplicationLifetime _appLifetime; private uint _clientCount = 0; - public PipeServerService(ILogger logger) + public PipeServerService(ILogger logger, IHostApplicationLifetime appLifetime) { _logger = logger; + _appLifetime = appLifetime; } public string? Token { get; set; } @@ -35,7 +35,7 @@ private async Task ServerLoop() _logger.LogInformation("[{Id}] Starting new server loop", id); - await pipeServerStream.WaitForConnectionAsync(); + await pipeServerStream.WaitForConnectionAsync(_appLifetime.ApplicationStopped); #pragma warning disable CS4014 OsTask.Run(ServerLoop); #pragma warning restore CS4014