public void Stop()
{
Thread localThread = null;
lock(stopstartSemaphore)
{
Tracer.Info("Stopping multicast discovery agent worker thread");
localThread = worker;
worker = null;
// Changing the isStarted flag will signal the thread that it needs to shut down.
isStarted = false;
}
if(localThread != null)
{
// wait for the worker to stop.
if(!localThread.Join(WORKER_KILL_TIME_SECONDS))
{
Tracer.Info("!! Timeout waiting for multicast discovery agent localThread to stop");
localThread.Abort();
}
}
Tracer.Info("Multicast discovery agent worker thread joined");
}