Add Stop methods for C# servers.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665538 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/csharp/src/Server/TSimpleServer.cs b/lib/csharp/src/Server/TSimpleServer.cs
index b2a70fe..ff59fc3 100644
--- a/lib/csharp/src/Server/TSimpleServer.cs
+++ b/lib/csharp/src/Server/TSimpleServer.cs
@@ -22,6 +22,7 @@
 	/// </summary>
 	class TSimpleServer : TServer
 	{
+		private bool stop = false;
 		public TSimpleServer(TProcessor processor,
 						  TServerTransport serverTransport)
 			:base(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory())
@@ -65,7 +66,7 @@
 				return;
 			}
 
-			while (true)
+			while (!stop)
 			{
 				TTransport client = null;
 				TTransport inputTransport = null;
@@ -103,6 +104,24 @@
 					outputTransport.Close();
 				}
 			}
+
+			if (stop)
+			{
+				try
+				{
+					serverTransport.Close();
+				}
+				catch (TTransportException ttx)
+				{
+					Console.Error.WriteLine("TServerTrasnport failed on close: " + ttx.Message);
+				}
+				stop = false;
+			}
+		}
+
+		public override void Stop()
+		{
+			stop = true;
 		}
 	}
 }