private void Run() { //bool debugging = false; //while (!debugging) // Thread.Sleep(100); var wtr = new EventLogWriter(ServiceName); try { wtr.WriteLine("Service initializing..."); _ci.Run(_arguments, wtr, wtr, new BlockingReader(_shutdown)); } catch (Exception e) { try { wtr.WriteLine(e.ToString()); } catch { } } finally { if (_shutdown.WaitOne(0, false) == false) { wtr.WriteLine("The command unexpectedly terminated."); Environment.Exit(1); } } }