diff --git a/src/Coherence/Util/Daemon/Daemon.cs b/src/Coherence/Util/Daemon/Daemon.cs
index 5b0987b..74e8cb1 100644
--- a/src/Coherence/Util/Daemon/Daemon.cs
+++ b/src/Coherence/Util/Daemon/Daemon.cs
@@ -590,7 +590,7 @@ public virtual void Stop()
// Once IsExiting is set the daemon's thread will attempt to clear any interrupts and then proceed to OnExit.
// In order to ensure that this doesn't occur before we actually get to interrupt the thread we synchronize this method
// as well as Run's call to clear the interrupt.
- lock (ExitMonitor)
+ using (BlockingLock l = BlockingLock.Lock(ExitMonitor))
{
// only go through Stop() once to prevent spurious interrupts during OnExit()
if (!IsExiting)
@@ -611,6 +611,45 @@ public virtual void Stop()
}
}
+ ///
+ /// Wait for the Daemon thread to stop.
+ ///
+ ///
+ ///
+ /// The number of milliseconds to wait for, or zero for infinite.
+ ///
+ ///
+ ///
+ /// true if the thread is no longer running.
+ ///
+ ///
+ /// Coherence 14.1.2.0
+ public virtual bool Join(int millis)
+ {
+ try
+ {
+ Thread thread = this.Thread;
+ if (thread != null)
+ {
+ if (millis > 0)
+ {
+ thread.Join(millis);
+ }
+ else
+ {
+ thread.Join();
+ }
+ return !thread.IsAlive;
+ }
+ return true;
+ }
+ catch (ThreadInterruptedException)
+ {
+ Thread.CurrentThread.Interrupt();
+ return false;
+ }
+ }
+
///
/// This method is called right after this daemon's thread starts.
///
@@ -669,7 +708,7 @@ public virtual void Run()
try
{
// see comment in Stop()
- lock (ExitMonitor)
+ using (BlockingLock l = BlockingLock.Lock(ExitMonitor))
{
try
{
diff --git a/src/Coherence/Util/Daemon/QueueProcessor/Service/Service.cs b/src/Coherence/Util/Daemon/QueueProcessor/Service/Service.cs
index 3e71813..2ac62c3 100644
--- a/src/Coherence/Util/Daemon/QueueProcessor/Service/Service.cs
+++ b/src/Coherence/Util/Daemon/QueueProcessor/Service/Service.cs
@@ -647,7 +647,7 @@ protected override void OnExit()
// give the chance for the daemon to drain it's queue
try
{
- daemon.Thread.Join(1000);
+ daemon.Join(1000);
}
catch (ThreadInterruptedException)
{