当前位置: 首页 > news >正文

大理建设招标有限公司网站wordpress图片怎么居中

大理建设招标有限公司网站,wordpress图片怎么居中,做攻略的网站,沧浪网页设计报价Quartz.NET是功能齐全的开源作业调度系统#xff0c;可用于最小的应用程序到大型企业系统。Quartz.NET具有三个主要概念#xff1a;•job#xff1a;运行的后台任务•trigger#xff1a;控制后台任务运行的触发器。•scheduler#xff1a;协调job和triggerASP.NET Core通过… Quartz.NET是功能齐全的开源作业调度系统可用于最小的应用程序到大型企业系统。Quartz.NET具有三个主要概念•job运行的后台任务•trigger控制后台任务运行的触发器。•scheduler协调job和triggerASP.NET Core通过托管服务对运行“后台任务”具有良好的支持托管服务在ASP.NET Core应用程序启动时启动并在应用程序生存期内在后台运行Quartz.NET版本3.2.0通过Quartz.Extensions.Hosting包引入了对该模式的直接支持Quartz.Extensions.Hosting可以与ASP.NET Core应用程序一起使用也可以与基于“通用主机”的工作程序服务一起使用。虽然.NET Core可以创建“定时”后台服务例如每10分钟运行一次任务但Quartz.NET提供了更为强大的解决方案, 通过使用Cron表达式您可以确保任务在特定时间例如凌晨2:30运行或仅在特定的几天运行或这些时间的任意组合。Quartz.NET还允许您以集群方式运行应用程序的多个实例以便在任何时候都只能运行一个实例。安装Quartz.NETQuartz.NET是一个.NET Standard 2.0 NuGet软件包所以大部分项目都是支持的你可以运行安装命令dotnet add package Quartz.Extensions.Hosting,或者在NNuget可视化安装如果查看该项目的.csproj应该是下边这样Project SdkMicrosoft.NET.Sdk.WorkerPropertyGroupTargetFrameworknet5.0/TargetFrameworkUserSecretsIddotnet-QuartzWorkerService-9D4BFFBE-BE06-4490-AE8B-8AF1466778FD/UserSecretsId/PropertyGroupItemGroupPackageReference IncludeMicrosoft.Extensions.Hosting Version5.0.0 /PackageReference IncludeQuartz.Extensions.Hosting Version3.2.3 //ItemGroup /Project 安装完成以后这个包会自动安装 Quartz.NET包接下来我们需要在我们的应用程序中注册Quartz服务和Quartz 。添加Quartz.NET hosted service修改Program.cs注册服务public class Program {public static void Main(string[] args){CreateHostBuilder(args).Build().Run();}public static IHostBuilder CreateHostBuilder(string[] args) Host.CreateDefaultBuilder(args).ConfigureServices((hostContext, services) {// Add the required Quartz.NET servicesservices.AddQuartz(q {// Use a Scoped container to create jobs. Ill touch on this laterq.UseMicrosoftDependencyInjectionScopedJobFactory();});// Add the Quartz.NET hosted serviceservices.AddQuartzHostedService(q q.WaitForJobsToComplete true);// other config}); } UseMicrosoftDependencyInjectionScopedJobFactory(),这个地方告诉Quartz.NET注册一个IJobFactory然后从DI容器中获取Job这样也可以使用 Scoped 类型的服务。WaitForJobsToComplete()当程序关闭时此设置可确保Quartz.NET在退出之前等待Job正常结束。如果现在运行您的应用程序您将看到Quartz服务启动并将有很多日志输出到控制台info: Quartz.Core.SchedulerSignalerImpl[0]Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl info: Quartz.Core.QuartzScheduler[0]Quartz Scheduler v.3.2.3.0 created. info: Quartz.Core.QuartzScheduler[0]JobFactory set to: Quartz.Simpl.MicrosoftDependencyInjectionJobFactory info: Quartz.Simpl.RAMJobStore[0]RAMJobStore initialized. info: Quartz.Core.QuartzScheduler[0]Scheduler meta-data: Quartz Scheduler (v3.2.3.0) QuartzScheduler with instanceId NON_CLUSTEREDScheduler class: Quartz.Core.QuartzScheduler - running locally.NOT STARTED.Currently in standby mode.Number of jobs executed: 0Using thread pool Quartz.Simpl.DefaultThreadPool - with 10 threads.Using job-store Quartz.Simpl.RAMJobStore - which does not support persistence. and is not clustered.info: Quartz.Impl.StdSchedulerFactory[0]Quartz scheduler QuartzScheduler initialized info: Quartz.Impl.StdSchedulerFactory[0]Quartz scheduler version: 3.2.3.0 info: Quartz.Core.QuartzScheduler[0]Scheduler QuartzScheduler_$_NON_CLUSTERED started. info: Microsoft.Hosting.Lifetime[0]Application started. Press CtrlC to shut down. ... 现在您已经将Quartz作为托管服务运行在您的应用程序中但是现在还没有添加需要运行的Job。创建一个IJob这个地方我创建一个简单的服务并且我可以从构造函数中获取服务。using Microsoft.Extensions.Logging; using Quartz; using System.Threading.Tasks;[DisallowConcurrentExecution] public class HelloWorldJob : IJob {private readonly ILoggerHelloWorldJob _logger;public HelloWorldJob(ILoggerHelloWorldJob logger){_logger logger;}public Task Execute(IJobExecutionContext context){_logger.LogInformation(Hello world!);return Task.CompletedTask;} } 我还用[DisallowConcurrentExecution]特性防止Quartz.NET尝试同时运行同一个作业。设置Job这个地方通常使用Cron表达式来设置job的执行时间。public static IHostBuilder CreateHostBuilder(string[] args) Host.CreateDefaultBuilder(args).ConfigureServices((hostContext, services) {services.AddQuartz(q {q.UseMicrosoftDependencyInjectionScopedJobFactory();// Create a key for the jobvar jobKey new JobKey(HelloWorldJob);// Register the job with the DI containerq.AddJobHelloWorldJob(opts opts.WithIdentity(jobKey));// Create a trigger for the jobq.AddTrigger(opts opts.ForJob(jobKey) // link to the HelloWorldJob.WithIdentity(HelloWorldJob-trigger) // give the trigger a unique name.WithCronSchedule(0/5 * * * * ?)); // run every 5 seconds});services.AddQuartzHostedService(q q.WaitForJobsToComplete true);// ...}); 现在运行应用程序您将看到和以前相同的启动消息然后每隔5秒钟就会看到HelloWorldJob写入控制台的信息将配置提取到appsettings.json一般情况我们都不会把cron表达式写死在代码中一般是设置在appsettings.json中{Quartz: {HelloWorldJob: 0/5 * * * * ?} } 为了更简单的注册服务这个地方我简单做了一个封装这样也更灵活。public static class ServiceCollectionQuartzConfiguratorExtensions {public static void AddJobAndTriggerT(this IServiceCollectionQuartzConfigurator quartz,IConfiguration config)where T : IJob{// Use the name of the IJob as the appsettings.json keystring jobName typeof(T).Name;// Try and load the schedule from configurationvar configKey $Quartz:{jobName};var cronSchedule config[configKey];// Some minor validationif (string.IsNullOrEmpty(cronSchedule)){throw new Exception($No Quartz.NET Cron schedule found for job in configuration at {configKey});}// register the job as beforevar jobKey new JobKey(jobName);quartz.AddJobT(opts opts.WithIdentity(jobKey));quartz.AddTrigger(opts opts.ForJob(jobKey).WithIdentity(jobName -trigger).WithCronSchedule(cronSchedule)); // use the schedule from configuration} } 然后修改Program.cs然后使用扩展方法public class Program {public static void Main(string[] args) CreateHostBuilder(args).Build().Run();public static IHostBuilder CreateHostBuilder(string[] args) Host.CreateDefaultBuilder(args).ConfigureServices((hostContext, services) {services.AddQuartz(q {q.UseMicrosoftDependencyInjectionScopedJobFactory();// Register the job, loading the schedule from configurationq.AddJobAndTriggerHelloWorldJob(hostContext.Configuration);});services.AddQuartzHostedService(q q.WaitForJobsToComplete true);}); } 再次运行该应用程序将提供相同的输出Job每5秒输入一次信息。原文作者: andrewlock 原文链接 https://andrewlock.net/using-quartz-net-with-asp-net-core-and-worker-services/[1]最后欢迎扫码关注我们的公众号 【全球技术精选】专注国外优秀博客的翻译和开源项目分享也可以添加QQ群 897216102References[1] https://andrewlock.net/using-quartz-net-with-asp-net-core-and-worker-services/: https://andrewlock.net/using-quartz-net-with-asp-net-core-and-worker-services/
http://www.pierceye.com/news/595948/

相关文章:

  • 建个门户网站网站开发人员配备
  • 营销型网站建设 上海工程造价
  • 做暧暧暖网站想建个企业网站
  • 南通做外贸的公司网站建筑招聘求职网
  • 网站排名顾问江苏省建设网站首页
  • 青岛找网站建设公司印记室内设计网站
  • 上海网站建设聚众网络网站对域名
  • 可做百科资料参考的网站福州网页定制
  • 开发一个网站需要多长时间高端网站定制开发设计制作
  • 桐乡做网站的公司视频网站建站费用
  • 企业网站建设服务网站制作的困难与解决方案
  • 宜昌营销型网站内存优化大师
  • 做购物网站的费用上海有名的效果图公司
  • 站长统计网站统计建立自己的网站软件有
  • 单页网站制作系统装修的网站都有哪些
  • 什么样的网站可以做站内站外贸网站wordpress
  • 网站栏目策划方案上不了建设银行网站
  • 深圳网络营销网站推广方法大连网页设计制作公司
  • 去哪想找人帮我做网站网站开发连接形式
  • 网龙公司有做网站吗北京建设银行支行查询官方网站
  • 本地推广找哪些网站wordpress isux主题
  • 写作网站可保存德阳网站建设公司
  • 找人做网站要密码吗榆林网站seo
  • 不同网站建设报价单深圳室内设计公司排行
  • wap网站价格用python做网站的多吗
  • 为什么要找对做网站的公司枣阳网站建设等服务
  • 有阿里云的主机了怎么做网站北京做网站ezhixi
  • 物业网站模板下载支付宝官网登录入口
  • 医疗网站模版北京建筑信息平台
  • 关于网站建设电话销售的开场白爱网站最新发布址