c# - CrystalQuartz 在作为 Windows 服务运行时不工作
问题描述
我在我的石英调度程序项目中添加了水晶石英以显示仪表板(检查链接)。当我将应用程序作为控制台应用程序运行时,下面的代码工作正常。但是当我们将它作为 Windows 服务部署在同一台机器上时它不起作用。它甚至没有抛出任何异常或任何登录事件记录器。
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");
当我们将应用程序部署为 Windows 服务时,在浏览器中打开链接“无法访问此站点”时出现以下错误。但是当我们将它作为控制台运行时它工作正常。
解决方案
最后,我通过将 console.readline 替换为下面的代码来解决它
System.Threading.ManualResetEvent ojbManualResetEvent = new System.Threading.ManualResetEvent(false);
ojbManualResetEvent.WaitOne();
推荐阅读
- jquery - 添加新行时,jQuery 在表格上触发自定义事件
- elixir - 在 Ubuntu 中升级到 Elixir 1.7
- vba - 如何使用 API 将图像内联嵌入到新的 Wordpress 帖子中
- apache-spark - 尽管没有从停机的机器上读取所有数据,但 spark 继续执行任务
- reactjs - 如何将样式化组件用于未出现在初始渲染中的元素?
- azure-pipelines-release-pipeline - VSTS 部署代理:无法绑定到 CoreCLR
- java - 从类中调用许多类的函数而不重置值
- pandas - 将所有非空转换为小写
- python - twitter 完整档案搜索 python
- laravel - 无法声明类 App\User,因为该名称已在使用中