コード例 #1
0
        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();
        }
コード例 #2
0
        public MailEnableService()
        {
            mailEnableManager = new MailEnableManager();

            InitializeComponent();
        }