protected override void OnStart(string[] args) { // Create service manager this.mailEnableManager = new MailEnableManager(); // Getting workers from configuration file MailEnableSection config = (MailEnableSection)ConfigurationManager.GetSection("MailEnable"); // Add each worker to manager foreach (MailEnableWorkerElement worker in config.Instances) { try { Type type = Type.GetType(worker.Assembly); var workerObj = (WorkerBase)Activator.CreateInstance(type, new object[] { worker.PoolingInterval }); this.mailEnableManager.AddWorker(workerObj); } catch (Exception ex) { throw ex; } } mailEnableManager.Run(); }