protected override void OnStart(string[] args)
{
// Since we are running as a service, setup an event log
string eventLogSource = "DiskSpaceCloudWatchMonitor";
if (!EventLog.SourceExists(eventLogSource))
{
// Requires to be administrator for this to succeed
EventLog.CreateEventSource(eventLogSource, "Eleven41");
}
_eventLog = new EventLog();
_eventLog.Source = eventLogSource;
// Start our main worker thread
new System.Threading.Thread(new ThreadStart(Run)).Start();
// When we leave here, our service will be running
// Why use a worker thread and not a timer?
// Original implementation had a timer, but the timer
// seemed to mysteriously stop ticking after about 15 minutes.
// No solution was found, so I reverted back to a worker thread.
}