Skip to content

Commit

Permalink
Explicitly created threads now set IsBackground=true to avoid prevent…
Browse files Browse the repository at this point in the history
…ing a process using this library from terminating. (#354)
  • Loading branch information
SkinnySackboy authored and ColinSullivan1 committed Jan 13, 2020
1 parent 2687668 commit b4c7ca3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/NATS.Client/Conn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ private void spinUpSocketWatchers()
readLoopStartEvent.Set();
readLoop();
});
t.IsBackground = true;
t.Start();
t.Name = generateThreadName("Reader");
wg.Add(t);
Expand All @@ -998,6 +999,7 @@ private void spinUpSocketWatchers()
flusherStartEvent.Set();
flusher();
});
t.IsBackground = true;
t.Start();
t.Name = generateThreadName("Flusher");
wg.Add(t);
Expand Down Expand Up @@ -1481,6 +1483,7 @@ private void processReconnect()
{
doReconnect();
});
t.IsBackground = true;
t.Name = generateThreadName("Reconnect");
t.Start();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Samples/Benchmark/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ void runReqReply(string testName, long testCount, long testSize)
subConn.Flush();
}
});
t.IsBackground = true;
t.Start();

Thread.Sleep(1000);
Expand Down Expand Up @@ -413,6 +414,7 @@ async Task runReqReplyAsync(string testName, long testCount, long testSize)
subConn.Flush();
}
});
t.IsBackground = true;
t.Start();

Thread.Sleep(1000);
Expand Down

0 comments on commit b4c7ca3

Please sign in to comment.