简体   繁体   English

作为Windows服务运行时CrystalQuartz不起作用

[英]CrystalQuartz not working when running as windows service

I have added crystal quartz in my quartz scheduler project to show the dashboard ( check link ). 我在石英调度程序项目中添加了石英晶体,以显示仪表板( 参见链接 )。 below code works fine when I am running the application as a console app. 当我将应用程序作为控制台应用程序运行时,以下代码可以正常工作。 but it does not work when we deploy it as windows service on the same machine. 但是当我们将其作为Windows服务部署在同一台计算机上时,它不起作用。 it's not even throwing any exception nor any log in event logger. 它甚至不会引发任何异常,也不会在事件记录器中进行任何登录。

IScheduler scheduler = SetupScheduler();
                Action<IAppBuilder> startup = app => 
                {
                    app.UseCrystalQuartz(scheduler);
                };

                Console.WriteLine("Starting self-hosted server...");
                using (WebApp.Start("http://localhost:9000/", startup))
                {
                    Console.WriteLine("Server is started");
                    Console.WriteLine();
                    Console.WriteLine("Check http://localhost:9000/quartz to see jobs information");
                    Console.WriteLine();

                    Console.WriteLine("Starting scheduler...");
                    scheduler.Start();

                    Console.WriteLine("Scheduler is started");
                    Console.WriteLine();
                    Console.WriteLine("Press [ENTER] to close");     
                    Console.ReadLine();     
                }

                Console.WriteLine("Shutting down...");
                scheduler.Shutdown(waitForJobsToComplete: true);
                Console.WriteLine("Scheduler has been stopped");

when we deploy the application as windows service I am getting below error while opening the link in the browser "This site can't be reached". 当我们将应用程序部署为Windows服务时,在浏览器中打开“无法访问此站点”链接时,出现以下错误。 but its working fine when we run it as a console. 但是当我们将其作为控制台运行时,它的工作正常。

finally, I solved it by replacing console.readline to below code 最后,我通过将console.readline替换为以下代码来解决了该问题

System.Threading.ManualResetEvent ojbManualResetEvent = new System.Threading.ManualResetEvent(false);
                ojbManualResetEvent.WaitOne();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行Windows服务时出现FileNotFoundException - FileNotFoundException when running a Windows Service 在带有“本地系统帐户”的“ Windows服务”下运行时,.NET Windows 7截屏不起作用 - .NET Windows 7 take screenshot not working when running under 'Windows Service' with 'Local System Account' 作为Windows服务运行时应用程序的异常行为 - Strange behaviour of app when running as windows service 在Windows Service中运行线程时出现错误1607 - Error 1607 when running thread in windows service 运行 Windows 服务时拒绝访问 - Access Denied when running Windows Service 作为Windows服务运行时的PCSC.InvalidContextException - PCSC.InvalidContextException when running as a Windows service 运行Windows服务时计时器触发两次 - Timer fired twice when running Windows service 在Windows服务中运行的线程中最终不会执行 - Finally is not executed when in a Thread running in a Windows Service 在调试器中运行的应用程序连接到Web服务,但作为Windows Service运行时不连接 - Application running in debugger connects to webservice in but not when running as windows service .Net Core 6 Worker Service 在作为 Windows 服务运行时不写入日志 - .Net Core 6 Worker Service not writing to Logs when running as a Windows Service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM