问题描述
我刚开始使用 Quartz.net 并将其作为服务运行.我创建了一个 Job 并将生成的 .dll 移动到 Quartz 文件夹,并在 jobs.xml 文件中添加了一个新条目以每 3 秒启动一次.
I just started with Quartz.net and I have it running as a service. I created a Job and moved the resulting .dll to the Quartz folder and added a new entry to the jobs.xml file to kick it off every 3 seconds.
我更新了作业 .dll,但它正在被 Quartz 使用(或被锁定).
I updated the job .dll but it is in use by Quartz (or is locked).
是否可以在不重新启动 Quartz 服务的情况下更新 .dll?如果不是,如果我停止/启动 Quartz 服务,长时间运行的作业会发生什么?
Is it possible to update the .dll without restarting the Quartz service? If not what would happen to a long running job if I did stop/start the Quartz service?
推荐答案
如果不重新启动服务,您将无法更新作业 dll.服务器启动后,它会加载作业 dll,并且加载的类型会保留在内存中.这就是 .NET 运行时的工作方式.要实现诸如动态重新加载之类的功能,您需要使用以编程方式创建的应用域等.
You cannot update the job dll without restarting the service. Once the server has started it loads the the job dll and the loaded types stay in memory. This is how .NET runtime works. To achieve something like dynamic reloading you would need to use programmatically created app domains etc.
如果您停止调度程序,您可以传递一个 bool 参数是否先等待作业完成.这样您就可以安全地完成作业,并且在调度程序关闭的同时不会产生新的作业.
If you stop the scheduler you can pass a bool parameter whether to wait for jobs to complete first. Then you would be safe with jobs completing and no new ones would spawn meanwhile the scheduler is shutting down.
这篇关于无需重启服务即可更新 Quartz.NET 作业 DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!