static void Main(string[] args)
        {
            //setup dependencies
            var builder = new ContainerBuilder();
            Console.WriteLine("Setting up dependencies");
            builder.Register<IisServerWorkerProcessCpuLister>(c => new IisServerWorkerProcessCpuLister()).As<IPerformanceCounterLister>();
            //builder.Register<PerformanceCounterLister>(c => new PerformanceCounterLister()).As<IPerformanceCounterLister>();

            //setup manager
            var manager = new CounterManager(builder);
            manager.WriteToLog = x => Console.WriteLine("{0:yyyyMMdd-HHmmss} {1}", DateTime.Now, x);
            manager.Start();
        }
        protected override void OnStart(string[] args)
        {
            serviceThread = new Thread(new ThreadStart(() =>
                {
                    try
                    {

                        //set up logging
                        string eventLogSource = "PC2CW Service";
                        if (!EventLog.SourceExists(eventLogSource))
                            EventLog.CreateEventSource(eventLogSource, "Application");

                        //setup dependencies
                        var builder = new ContainerBuilder();
                        EventLog.WriteEntry(eventLogSource, "Setting up dependencies", EventLogEntryType.Information);

                        //todo: configuration based provider setup
                        builder.Register<IisServerWorkerProcessCpuLister>(c => new IisServerWorkerProcessCpuLister()).As<IPerformanceCounterLister>();
                        builder.Register<IisServerSiteTrafficCountLister>(c => new IisServerSiteTrafficCountLister()).As<IPerformanceCounterLister>();

                        //setup manager
                        manager = new CounterManager(builder);
                        manager.WriteToLog = x =>
                        {
                            //do not log every single status report, as this means we're storing all the stats in the event log!
                            //  this should only be used in debug
            #if DEBUG
                            string message = String.Format("{0:yyyyMMdd-HHmmss} {1}", DateTime.Now, x);
                            EventLog.WriteEntry(eventLogSource, message, EventLogEntryType.Information);
            #endif
                        };
                        EventLog.WriteEntry(eventLogSource, "Starting CounterManager...", EventLogEntryType.Information);
                        manager.Start();
                        EventLog.WriteEntry(eventLogSource, "CounterManager started", EventLogEntryType.Information);
                    }
                    catch (Exception ex)
                    {
                        //todo: log eception stopping
                        string eventLogSource = "PC2CW Service";
                        if (!EventLog.SourceExists(eventLogSource))
                            EventLog.CreateEventSource(eventLogSource, "Application");

                        EventLog.WriteEntry(eventLogSource, "Error in main service thread: " + ex.Message + Environment.NewLine + ex.StackTrace, EventLogEntryType.Error);
                    }

                }));

                serviceThread.Start();
        }