From a652ea02475c3d25148ad7f40076340f98ed6390 Mon Sep 17 00:00:00 2001 From: Ziya Suzen Date: Tue, 10 Oct 2023 20:08:37 +0100 Subject: [PATCH] Revert test proxy threads to tasks --- tests/NATS.Client.TestUtilities/NatsProxy.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/NATS.Client.TestUtilities/NatsProxy.cs b/tests/NATS.Client.TestUtilities/NatsProxy.cs index 7383b3156..ad2c887d9 100644 --- a/tests/NATS.Client.TestUtilities/NatsProxy.cs +++ b/tests/NATS.Client.TestUtilities/NatsProxy.cs @@ -24,7 +24,7 @@ public NatsProxy(int port, ITestOutputHelper outputHelper, bool trace) _tcpListener.Start(); _watch.Restart(); - new Thread(() => + Task.Run(() => { var client = 0; while (true) @@ -48,7 +48,7 @@ public NatsProxy(int port, ITestOutputHelper outputHelper, bool trace) var n = client++; #pragma warning disable CS4014 - new Thread(() => + Task.Run(() => { var stream1 = tcpClient1.GetStream(); var sr1 = new StreamReader(stream1, Encoding.ASCII); @@ -58,19 +58,19 @@ public NatsProxy(int port, ITestOutputHelper outputHelper, bool trace) var sr2 = new StreamReader(stream2, Encoding.ASCII); var sw2 = new StreamWriter(stream2, Encoding.ASCII); - new Thread(() => + Task.Run(() => { while (NatsProtoDump(n, "C", sr1, sw2, ClientInterceptor)) { } - }) { IsBackground = true, Name = $"nats-proxy-writer-{n}" }.Start(); + }); while (NatsProtoDump(n, $"S", sr2, sw1, ServerInterceptor)) { } - }) { IsBackground = true, Name = $"nats-proxy-reader-{n}" }.Start(); + }); } - }) { IsBackground = true, Name = "nats-proxy-srv" }.Start(); + }); var stopwatch = Stopwatch.StartNew(); while (stopwatch.Elapsed < TimeSpan.FromSeconds(10))