diff --git a/test/ANCMStressTestApp/Program.cs b/test/ANCMStressTestApp/Program.cs index 7bfe0bae9f..b0edb5b7f2 100644 --- a/test/ANCMStressTestApp/Program.cs +++ b/test/ANCMStressTestApp/Program.cs @@ -17,9 +17,6 @@ namespace ANCMStressTestApp { public class Program { - public static IApplicationLifetime AppLifetime; - public static CancellationTokenSource Cts = new CancellationTokenSource(); - public static void Main(string[] args) { var host = new WebHostBuilder() @@ -32,14 +29,6 @@ namespace ANCMStressTestApp .UseStartup() .Build(); - AppLifetime = (IApplicationLifetime)host.Services.GetService(typeof(IApplicationLifetime)); - AppLifetime.ApplicationStopping.Register( - () => { - Cts.Cancel(); - Cts.Dispose(); - } - ); - host.Run(); } } diff --git a/test/ANCMStressTestApp/Startup.cs b/test/ANCMStressTestApp/Startup.cs index a374c65b40..be0969ec77 100644 --- a/test/ANCMStressTestApp/Startup.cs +++ b/test/ANCMStressTestApp/Startup.cs @@ -171,7 +171,9 @@ namespace ANCMStressTestApp // Get the WebSocket object var ws = WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol: null, keepAliveInterval: TimeSpan.FromMinutes(2)); - await Echo(ws, Program.Cts.Token); + var appLifetime = app.ApplicationServices.GetRequiredService(); + + await Echo(ws, appLifetime.ApplicationStopping); }); }