Skip to content

Commit

Permalink
Revert test proxy threads to tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed Oct 10, 2023
1 parent fe70da1 commit a652ea0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/NATS.Client.TestUtilities/NatsProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand All @@ -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))
Expand Down

0 comments on commit a652ea0

Please sign in to comment.