From b4c7ca38d14f9f8867a2c543d7293654de34b152 Mon Sep 17 00:00:00 2001 From: SkinnySackboy Date: Tue, 14 Jan 2020 00:32:48 +0100 Subject: [PATCH] Explicitly created threads now set IsBackground=true to avoid preventing a process using this library from terminating. (#354) --- src/NATS.Client/Conn.cs | 3 +++ src/Samples/Benchmark/Benchmark.cs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/NATS.Client/Conn.cs b/src/NATS.Client/Conn.cs index a97481b36..4ef90b79c 100644 --- a/src/NATS.Client/Conn.cs +++ b/src/NATS.Client/Conn.cs @@ -989,6 +989,7 @@ private void spinUpSocketWatchers() readLoopStartEvent.Set(); readLoop(); }); + t.IsBackground = true; t.Start(); t.Name = generateThreadName("Reader"); wg.Add(t); @@ -998,6 +999,7 @@ private void spinUpSocketWatchers() flusherStartEvent.Set(); flusher(); }); + t.IsBackground = true; t.Start(); t.Name = generateThreadName("Flusher"); wg.Add(t); @@ -1481,6 +1483,7 @@ private void processReconnect() { doReconnect(); }); + t.IsBackground = true; t.Name = generateThreadName("Reconnect"); t.Start(); } diff --git a/src/Samples/Benchmark/Benchmark.cs b/src/Samples/Benchmark/Benchmark.cs index a8d685e25..0c8e22bf5 100644 --- a/src/Samples/Benchmark/Benchmark.cs +++ b/src/Samples/Benchmark/Benchmark.cs @@ -369,6 +369,7 @@ void runReqReply(string testName, long testCount, long testSize) subConn.Flush(); } }); + t.IsBackground = true; t.Start(); Thread.Sleep(1000); @@ -413,6 +414,7 @@ async Task runReqReplyAsync(string testName, long testCount, long testSize) subConn.Flush(); } }); + t.IsBackground = true; t.Start(); Thread.Sleep(1000);