The OnStart event handler is not intended to contain the service's 'work' code. Instead try moving your looping code to a function that follows the WaitCallback delegate definition and call ThreadPool.QueueUserWorkItem in the OnStart event. This will allow the OnStart event handler to return quickly, thereby allowing your service is start quickly and respond to the Service Control in a timely manner.
Dan
Dan Dittenhafer
Posted: Visual C# General, Windows Service OnStart Event
The ServiceController class in the System.ServiceProcess namespace provides functionality to Start/Stop services. Try calling ServiceControler.Stop as in:
ServiceController cs = new ServiceController("MyService");
cs.Stop();
RizwanSharp
Posted: Visual C# General, Windows Service OnStart Event