I'm playing around with c# cos I was bored and I wanted to have a go at making a simple windows service that spits out a quote of the day if you telnet on a certain port.
I have it working but I'm not sure of the best way to stop the service. The OnStart method creates a thread and starts it. The method the thread executes is a permanent loop while(true){ create tcp listener etc..}
What is the cleanest way to cause the loop to break and the thread to return from the OnStop method of my service class?