简体   繁体   中英

Topshelf service not running automatically after first execution completes

I have a service which should run after every time it finishes, But topshelf hosted windows service runs one time when I start it but never run again?

Do I need to configure something.

My current configuration is

namespace RL.Reprice
{
    class Program
    {
        public static void Main()
        {
            HostFactory.Run(serviceConfig =>
            {
                log4net.Config.XmlConfigurator.Configure();
                serviceConfig.UseLog4Net();

                serviceConfig.Service<RepriceBook>(serviceInstance =>
                {
                    serviceInstance.ConstructUsing(
                        () => new RepriceBook());

                    serviceInstance.WhenStarted(
                        execute => execute.Start());

                    serviceInstance.WhenStopped(
                        execute => execute.Stop());

                    //    serviceInstance.WhenPaused(
                    //        execute => execute.Pause());

                    //    serviceInstance.WhenContinued(
                    //        execute => execute.Continue());
                });

                serviceConfig.EnableServiceRecovery(recoveryOption =>
                {
                    recoveryOption.RestartService(2);
                });

                serviceConfig.SetServiceName("RepriceService");
                serviceConfig.SetDisplayName("Reprice Book");
                serviceConfig.SetDescription("This is Repricer");

                serviceConfig.StartAutomatically();
            });                                   
        }
    }
}

使用Quartz.Net重复运行任务。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM