Applied patch to set worker thread as background thread.  Thanks to Iddo Shoham for the fix!
Fixes [AMQNET-166]. (See https://issues.apache.org/activemq/browse/AMQNET-166)

diff --git a/src/main/csharp/Transport/Discovery/Multicast/MulticastDiscoveryAgent.cs b/src/main/csharp/Transport/Discovery/Multicast/MulticastDiscoveryAgent.cs
index 684e054..ef9c60e 100644
--- a/src/main/csharp/Transport/Discovery/Multicast/MulticastDiscoveryAgent.cs
+++ b/src/main/csharp/Transport/Discovery/Multicast/MulticastDiscoveryAgent.cs
@@ -32,7 +32,7 @@
 		public const int MAX_SOCKET_CONNECTION_RETRY_ATTEMPS = 3;

 		public const int DEFAULT_BACKOFF_MILLISECONDS = 100;

 		public const int BACKOFF_MULTIPLIER = 2;

-        public const string DEFAULT_DISCOVERY_URI_STRING = "multicast://239.255.2.3:6155";

+		public const string DEFAULT_DISCOVERY_URI_STRING = "multicast://239.255.2.3:6155";

 		private const string TYPE_SUFFIX = "ActiveMQ-4.";

 		private const string ALIVE = "alive";

 		private const string DEAD = "dead";

@@ -69,10 +69,10 @@
 		{

 			lock(stopstartSemaphore)

 			{

-                if (discoveryUri == null)

-                {

-                    discoveryUri = new Uri(DEFAULT_DISCOVERY_URI_STRING);

-                }

+				if (discoveryUri == null)

+				{

+					discoveryUri = new Uri(DEFAULT_DISCOVERY_URI_STRING);

+				}

 

 				if(multicastSocket == null)

 				{

@@ -98,6 +98,7 @@
 				{

 					Tracer.Info("Starting multicast discovery agent worker thread");

 					worker = new Thread(new ThreadStart(worker_DoWork));

+					worker.IsBackground = true;

 					worker.Start();

 					isStarted = true;

 				}

@@ -182,15 +183,15 @@
 					int numBytes = multicastSocket.Receive(buffer);

 					receivedInfoRaw = System.Text.Encoding.UTF8.GetString(buffer, 0, numBytes);

 					// We have to remove all of the null bytes if there are any otherwise we just

-                    // take the whole string as is.

-                    if (receivedInfoRaw.IndexOf("\0") != -1)

-                    {

-                        receivedInfo = receivedInfoRaw.Substring(0, receivedInfoRaw.IndexOf("\0"));

-                    }

-                    else

-                    {

-                        receivedInfo = receivedInfoRaw;

-                    }

+					// take the whole string as is.

+					if (receivedInfoRaw.IndexOf("\0") != -1)

+					{

+						receivedInfo = receivedInfoRaw.Substring(0, receivedInfoRaw.IndexOf("\0"));

+					}

+					else

+					{

+						receivedInfo = receivedInfoRaw;

+					}

 

 					ProcessBrokerMessage(receivedInfo);

 				}

@@ -294,16 +295,16 @@
 			}

 		}

 

-        #region Properties

+		#region Properties

 

-        /// <summary>

-        /// This property indicates whether or not async send is enabled.

-        /// </summary>

-        public Uri DiscoveryURI

-        {

-            get { return discoveryUri; }

-            set { discoveryUri = value; }

-        }

+		/// <summary>

+		/// This property indicates whether or not async send is enabled.

+		/// </summary>

+		public Uri DiscoveryURI

+		{

+			get { return discoveryUri; }

+			set { discoveryUri = value; }

+		}

 

 		public bool IsStarted

 		{

@@ -314,11 +315,11 @@
 		{

 			get { return group; }

 			set { group = value; }

-        }

+		}

 

-        #endregion

+		#endregion

 

-        internal string MulticastType

+		internal string MulticastType

 		{

 			get { return group + "." + TYPE_SUFFIX; }

 		}