zoukankan      html  css  js  c++  java
  • Quartz.NET笔记(一) 概述

    配置

    有三种配置方式:

    1.编码方式: scheduler factory提供的NameValueCollection参数

    2.使用标准的 youapp.exe.config配置文件中的quartz-element

    3.应用程序根目录中的quartz.config配置文件

    注意:VS中要将配置文件设置为“Copy always”

    一个简单的例子:

    Program.cs

     1 using System;
     2 using System.Threading;
     3 
     4 using Quartz;
     5 using Quartz.Impl;
     6 
     7 namespace ConsoleApplication1
     8 {
     9     public class Program
    10     {
    11         private static void Main(string[] args)
    12         {
    13             try
    14             {
    15                 // Grab the Scheduler instance from the Factory 
    16                 IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
    17 
    18                 // and start it off
    19                 scheduler.Start();
    20 
    21                 // some sleep to show what's happening
    22                 Thread.Sleep(TimeSpan.FromSeconds(60));
    23 
    24                 // and last shut down the scheduler when you are ready to close your program
    25                 scheduler.Shutdown();
    26             }
    27             catch (SchedulerException se)
    28             {
    29                 Console.WriteLine(se);
    30             }
    31         }
    32     }
    33 }

    一旦使用StdSchedulerFactory.GetDefaultScheduler()一个scheduler ,应用程序默认将不会终止,直到调用scheduler.Shutdown()方法,因为那样会激活线程(非守护线程)。

    现在运行程序,不会显示任何东西,60秒过后,程序终止。

    Adding logging

      Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter { Level = Common.Logging.LogLevel.Info };

  • 相关阅读:
    Orchard CMS中如何打包不带源码的模块
    牛X的CSS3
    Docker指令
    Spring Boot 应用 发布到Docker
    Haproxy全透明代理
    TCP/IP协议理解
    ubuntu tomcat 部署java web
    UDP"打洞"原理
    java多线程-线程通信
    window环境下杀死tomcat
  • 原文地址:https://www.cnblogs.com/hzz521/p/5155479.html
Copyright © 2011-2022 走看看