text: (window.webpackJsonp=window.webpackJsonp||[]).push([[22],{209:function(e,n,t){"use strict";t.d(n,"a",(function(){return m})),t.d(n,"b",(function(){return j}));var a=t(0),r=t.n(a);function b(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function l(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach((function(n){b(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function o(e,n){if(null==e)return{};var t,a,r=function(e,n){if(null==e)return{};var t,a,r={},b=Object.keys(e);for(a=0;a<b.length;a++)t=b[a],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(a=0;a<b.length;a++)t=b[a],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var c=r.a.createContext({}),d=function(e){var n=r.a.useContext(c),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},m=function(e){var n=d(e.components);return r.a.createElement(c.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},O=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,b=e.originalType,i=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),m=d(t),O=a,j=m["".concat(i,".").concat(O)]||m[O]||p[O]||b;return t?r.a.createElement(j,l(l({ref:n},c),{},{components:t})):r.a.createElement(j,l({ref:n},c))}));function j(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var b=t.length,i=new Array(b);i[0]=O;var l={};for(var o in n)hasOwnProperty.call(n,o)&&(l[o]=n[o]);l.originalType=e,l.mdxType="string"==typeof e?e:a,i[1]=l;for(var c=2;c<b;c++)i[c]=t[c];return r.a.createElement.apply(null,i)}return r.a.createElement.apply(null,t)}O.displayName="MDXCreateElement"},98:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return i})),t.d(n,"metadata",(function(){return l})),t.d(n,"toc",(function(){return o})),t.d(n,"default",(function(){return d}));var a=t(3),r=t(7),b=(t(0),t(209)),i={id:"job",title:"26. \u5b9a\u65f6\u4efb\u52a1/\u540e\u53f0\u4efb\u52a1",sidebar_label:"26. \u5b9a\u65f6\u4efb\u52a1/\u540e\u53f0\u4efb\u52a1"},l={unversionedId:"job",id:"job",isDocsHomePage:!1,title:"26. \u5b9a\u65f6\u4efb\u52a1/\u540e\u53f0\u4efb\u52a1",description:"\u4ee5\u4e0b\u5185\u5bb9\u53ea\u9650 Furion 2.0.0 + \u7248\u672c\u4f7f\u7528\u3002",source:"@site/docs/job.mdx",sourceDirName:".",slug:"/job",permalink:"/furion/docs/job",editUrl:"https://gitee.com/dotnetchina/Furion/tree/master/handbook/docs/job.mdx",version:"current",lastUpdatedBy:"Monk",lastUpdatedAt:1618803530,formattedLastUpdatedAt:"4/19/2021",sidebar_label:"26. \u5b9a\u65f6\u4efb\u52a1/\u540e\u53f0\u4efb\u52a1",frontMatter:{id:"job",title:"26. \u5b9a\u65f6\u4efb\u52a1/\u540e\u53f0\u4efb\u52a1",sidebar_label:"26. \u5b9a\u65f6\u4efb\u52a1/\u540e\u53f0\u4efb\u52a1"},sidebar:"docs",previous:{title:"25. \u8f85\u52a9\u89d2\u8272\u670d\u52a1",permalink:"/furion/docs/process-service"},next:{title:"27. \u5fae\u670d\u52a1\u652f\u6301",permalink:"/furion/docs/microservice"}},o=[{value:"26.1 \u5173\u4e8e\u5b9a\u65f6\u4efb\u52a1",id:"261-\u5173\u4e8e\u5b9a\u65f6\u4efb\u52a1",children:[]},{value:"26.2 \u5982\u4f55\u5b9e\u73b0",id:"262-\u5982\u4f55\u5b9e\u73b0",children:[]},{value:"26.3 \u7f13\u9694\u65b9\u5f0f\u4f7f\u7528",id:"263-\u7f13\u9694\u65b9\u5f0f\u4f7f\u7528",children:[{value:"26.3.1 \u7279\u5b9a\u65f6\u95f4\u540e\u6267\u884c",id:"2631-\u7279\u5b9a\u65f6\u95f4\u540e\u6267\u884c",children:[]},{value:"26.3.2 \u914d\u7f6e\u4efb\u52a1\u4fe1\u606f",id:"2632-\u914d\u7f6e\u4efb\u52a1\u4fe1\u606f",children:[]},{value:"26.3.3 \u624b\u52a8\u542f\u52a8\u6267\u884c",id:"2633-\u624b\u52a8\u542f\u52a8\u6267\u884c",children:[]},{value:"26.3.4 \u6a21\u62df\u540e\u53f0\u6267\u884c",id:"2634-\u6a21\u62df\u540e\u53f0\u6267\u884c",children:[]},{value:"26.3.5 <code>ISpareTimeWorker</code> \u65b9\u5f0f",id:"2635-isparetimeworker-\u65b9\u5f0f",children:[]}]},{value:"26.4 \u95f4\u9694\u65b9\u5f0f\u4f7f\u7528",id:"264-\u95f4\u9694\u65b9\u5f0f\u4f7f\u7528",children:[{value:"26.4.1 \u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u6267\u884c",id:"2641-\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u6267\u884c",children:[]},{value:"26.4.2 \u914d\u7f6e\u4efb\u52a1\u4fe1\u606f",id:"2642-\u914d\u7f6e\u4efb\u52a1\u4fe1\u606f",children:[]},{value:"26.4.3 \u624b\u52a8\u542f\u52a8\u6267\u884c",id:"2643-\u624b\u52a8\u542f\u52a8\u6267\u884c",children:[]},{value:"26.4.4 <code>ISpareTimeWorker</code> \u65b9\u5f0f",id:"2644-isparetimeworker-\u65b9\u5f0f",children:[]}]},{value:"26.5 <code>Cron</code> \u8868\u8fbe\u5f0f\u4f7f\u7528",id:"265-cron-\u8868\u8fbe\u5f0f\u4f7f\u7528",children:[{value:"26.5.1 \u4ec0\u4e48\u662f <code>Cron</code> \u8868\u8fbe\u5f0f",id:"2651-\u4ec0\u4e48\u662f-cron-\u8868\u8fbe\u5f0f",children:[]},{value:"25.5.2 \u5e38\u89c1 <code>Cron</code> \u8868\u8fbe\u5f0f",id:"2552-\u5e38\u89c1-cron-\u8868\u8fbe\u5f0f",children:[]},{value:"25.5.3 \u5728\u7ebf\u751f\u6210 <code>Cron</code> \u8868\u8fbe\u5f0f",id:"2553-\u5728\u7ebf\u751f\u6210-cron-\u8868\u8fbe\u5f0f",children:[]},{value:"25.5.4 <code>Macro</code> \u6807\u8bc6\u7b26",id:"2554-macro-\u6807\u8bc6\u7b26",children:[]},{value:"25.5.5 \u4f7f\u7528 <code>Cron</code> \u8868\u8fbe\u5f0f",id:"2555-\u4f7f\u7528-cron-\u8868\u8fbe\u5f0f",children:[]},{value:"25.5.6 \u4f7f\u7528 <code>Macro</code> \u5360\u4f4d\u7b26",id:"2556-\u4f7f\u7528-macro-\u5360\u4f4d\u7b26",children:[]},{value:"25.5.7 \u914d\u7f6e\u4efb\u52a1\u4fe1\u606f",id:"2557-\u914d\u7f6e\u4efb\u52a1\u4fe1\u606f",children:[]},{value:"25.5.8 \u624b\u52a8\u542f\u52a8\u6267\u884c",id:"2558-\u624b\u52a8\u542f\u52a8\u6267\u884c",children:[]},{value:"26.5.9 <code>ISpareTimeWorker</code> \u65b9\u5f0f",id:"2659-isparetimeworker-\u65b9\u5f0f",children:[]}]},{value:"26.6 \u81ea\u5b9a\u4e49\u4e0b\u6b21\u6267\u884c\u65f6\u95f4",id:"266-\u81ea\u5b9a\u4e49\u4e0b\u6b21\u6267\u884c\u65f6\u95f4",children:[{value:"26.6.1 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u95f4\u9694\u65b9\u5f0f",id:"2661-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u95f4\u9694\u65b9\u5f0f",children:[]},{value:"26.6.2 \u9ad8\u7ea7\u81ea\u5b9a\u4e49 <code>Cron</code> \u8868\u8fbe\u5f0f",id:"2662-\u9ad8\u7ea7\u81ea\u5b9a\u4e49-cron-\u8868\u8fbe\u5f0f",children:[]}]},{value:"26.7 <code>ISpareTimeWorker</code> \u8bf4\u660e",id:"267-isparetimeworker-\u8bf4\u660e",children:[{value:"26.7.1 <code>[SpareTime]</code> \u7279\u6027",id:"2671-sparetime-\u7279\u6027",children:[]}]},{value:"26.8 <code>SpareTime</code> \u9759\u6001\u7c7b",id:"268-sparetime-\u9759\u6001\u7c7b",children:[{value:"26.8.1 \u521d\u59cb\u5316\u4efb\u52a1",id:"2681-\u521d\u59cb\u5316\u4efb\u52a1",children:[]},{value:"26.8.2 \u5b9e\u73b0\u540e\u53f0\u6267\u884c",id:"2682-\u5b9e\u73b0\u540e\u53f0\u6267\u884c",children:[]},{value:"26.8.3 \u5f00\u59cb\u4e00\u4e2a\u4efb\u52a1",id:"2683-\u5f00\u59cb\u4e00\u4e2a\u4efb\u52a1",children:[]},{value:"26.8.4 \u6682\u505c\u4e00\u4e2a\u4efb\u52a1",id:"2684-\u6682\u505c\u4e00\u4e2a\u4efb\u52a1",children:[]},{value:"26.8.5 \u53d6\u6d88\u4e00\u4e2a\u4efb\u52a1",id:"2685-\u53d6\u6d88\u4e00\u4e2a\u4efb\u52a1",children:[]},{value:"26.8.6 \u9500\u6bc1\u6240\u6709\u4efb\u52a1",id:"2686-\u9500\u6bc1\u6240\u6709\u4efb\u52a1",children:[]},{value:"26.8.7 \u83b7\u53d6\u6240\u6709\u4efb\u52a1",id:"2687-\u83b7\u53d6\u6240\u6709\u4efb\u52a1",children:[]},{value:"26.8.8 \u89e3\u6790 <code>Cron</code> \u8868\u8fbe\u5f0f",id:"2688-\u89e3\u6790-cron-\u8868\u8fbe\u5f0f",children:[]}]},{value:"26.9 <code>\u5e76\u884c</code>\u548c<code>\u4e32\u884c</code>\u6267\u884c\u65b9\u5f0f",id:"269-\u5e76\u884c\u548c\u4e32\u884c\u6267\u884c\u65b9\u5f0f",children:[{value:"26.9.1 <code>SpareTime</code> \u9759\u6001\u65b9\u5f0f\u6307\u5b9a",id:"2691-sparetime-\u9759\u6001\u65b9\u5f0f\u6307\u5b9a",children:[]},{value:"26.9.2 <code>ISpareTimeWorker</code> \u65b9\u5f0f",id:"2692-isparetimeworker-\u65b9\u5f0f",children:[]}]},{value:"26.10 \u4efb\u52a1\u5f02\u5e38\u5904\u7406",id:"2610-\u4efb\u52a1\u5f02\u5e38\u5904\u7406",children:[]},{value:"26.11 \u5982\u4f55\u5728\u4efb\u52a1\u4e2d\u89e3\u6790\u5bf9\u8c61",id:"2611-\u5982\u4f55\u5728\u4efb\u52a1\u4e2d\u89e3\u6790\u5bf9\u8c61",children:[]},{value:"26.12 \u5728 <code>BackgroundService</code> \u4e2d\u4f7f\u7528",id:"2612-\u5728-backgroundservice-\u4e2d\u4f7f\u7528",children:[{value:"26.12.1 \u95f4\u9694\u6267\u884c\u65b9\u5f0f",id:"26121-\u95f4\u9694\u6267\u884c\u65b9\u5f0f",children:[]},{value:"26.12.2 <code>Cron</code> \u8868\u8fbe\u5f0f\u6267\u884c\u65b9\u5f0f\uff0c",id:"26122-cron-\u8868\u8fbe\u5f0f\u6267\u884c\u65b9\u5f0f\uff0c",children:[]}]},{value:"26.13 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"2613-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],c={toc:o};function d(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(b.b)("wrapper",Object(a.a)({},c,t,{components:n,mdxType:"MDXLayout"}),Object(b.b)("div",{className:"admonition admonition-important alert alert--info"},Object(b.b)("div",{parentName:"div",className:"admonition-heading"},Object(b.b)("h5",{parentName:"div"},Object(b.b)("span",{parentName:"h5",className:"admonition-icon"},Object(b.b)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},Object(b.b)("path",{parentName:"svg",fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),"\u7248\u672c\u8bf4\u660e")),Object(b.b)("div",{parentName:"div",className:"admonition-content"},Object(b.b)("p",{parentName:"div"},"\u4ee5\u4e0b\u5185\u5bb9\u53ea\u9650 ",Object(b.b)("inlineCode",{parentName:"p"},"Furion 2.0.0 +")," \u7248\u672c\u4f7f\u7528\u3002"))),Object(b.b)("h2",{id:"261-\u5173\u4e8e\u5b9a\u65f6\u4efb\u52a1"},"26.1 \u5173\u4e8e\u5b9a\u65f6\u4efb\u52a1"),Object(b.b)("p",null,"\u987e\u540d\u601d\u4e49\uff0c\u5b9a\u65f6\u4efb\u52a1\u5c31\u662f\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u6216\u7b26\u5408\u67d0\u79cd\u65f6\u95f4\u89c4\u5f8b\u6267\u884c\u7684\u4efb\u52a1\u3002\u901a\u5e38\u5b9a\u65f6\u4efb\u52a1\u6709\u56db\u79cd\u65f6\u95f4\u8c03\u5ea6\u65b9\u5f0f\uff1a"),Object(b.b)("ul",null,Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"\u7f13\u9694\u65f6\u95f4")," \u65b9\u5f0f\uff1a\u5ef6\u8fdf\u591a\u5c11\u65f6\u95f4\u540e\u8c03\u914d\u4efb\u52a1\uff0c\u8fd9\u79cd\u65b9\u5f0f\u4efb\u52a1\u53ea\u4f1a\u88ab\u8c03\u7528\u4e00\u6b21\u3002"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"\u95f4\u9694\u65f6\u95f4")," \u65b9\u5f0f\uff1a\u6bcf\u9694\u4e00\u6bb5\u56fa\u5b9a\u65f6\u95f4\u8c03\u914d\u4efb\u52a1\uff0c\u65e0\u95f4\u65ad\u8c03\u7528\u4efb\u52a1\u3002"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"Cron \u8868\u8fbe\u5f0f")," \u65b9\u6cd5\uff1a\u901a\u8fc7 ",Object(b.b)("inlineCode",{parentName:"li"},"Cron")," \u8868\u8fbe\u5f0f\u8ba1\u7b97\u4e0b\u4e00\u6b21\u6267\u884c\u65f6\u95f4\u8fdb\u884c\u8c03\u914d\u4efb\u52a1\uff0c\u53ef\u4ee5\u914d\u7f6e\u7279\u5b9a\u65f6\u95f4\u8303\u56f4\u5185\u6267\u884c\uff0c\u4e5f\u53ef\u4ee5\u65e0\u95f4\u65ad\u6267\u884c\u3002"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"\u81ea\u5b9a\u4e49\u4e0b\u6b21\u6267\u884c\u65f6\u95f4"),"\uff1a\u53ef\u4ee5\u901a\u8fc7\u5404\u79cd\u903b\u8f91\u8fd0\u7b97\u8fd4\u56de\u4e0b\u4e00\u6b21\u6267\u884c\u65f6\u95f4")),Object(b.b)("h2",{id:"262-\u5982\u4f55\u5b9e\u73b0"},"26.2 \u5982\u4f55\u5b9e\u73b0"),Object(b.b)("p",null,Object(b.b)("inlineCode",{parentName:"p"},"Furion")," \u6846\u67b6\u63d0\u4f9b\u4e86\u4e24\u79cd\u65b9\u5f0f\u5b9e\u73b0\u5b9a\u65f6\u4efb\u52a1\uff1a"),Object(b.b)("ul",null,Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"SpareTime")," \u9759\u6001\u7c7b\uff1a",Object(b.b)("inlineCode",{parentName:"li"},"SpareTime")," \u9759\u6001\u7c7b\u63d0\u4f9b ",Object(b.b)("inlineCode",{parentName:"li"},"SpareTime.Do([options])")," \u65b9\u5f0f\u8c03\u7528\u3002"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"ISpareTimeWorker")," \u4f9d\u8d56\u65b9\u5f0f\uff1a\u901a\u8fc7\u81ea\u5b9a\u4e49\u7c7b\u5b9e\u73b0 ",Object(b.b)("inlineCode",{parentName:"li"},"ISpareTimeWorker")," \u63a5\u53e3\u5e76\u7f16\u5199\u4e00\u5b9a\u89c4\u5219\u7684\u65b9\u6cd5\u5373\u53ef\u3002",Object(b.b)("strong",{parentName:"li"},"\u9700\u8981\u5728 ",Object(b.b)("inlineCode",{parentName:"strong"},"Startup.cs")," \u4e2d\u6ce8\u518c ",Object(b.b)("inlineCode",{parentName:"strong"},"services.AddTaskScheduler()")))),Object(b.b)("h2",{id:"263-\u7f13\u9694\u65b9\u5f0f\u4f7f\u7528"},"26.3 \u7f13\u9694\u65b9\u5f0f\u4f7f\u7528"),Object(b.b)("h3",{id:"2631-\u7279\u5b9a\u65f6\u95f4\u540e\u6267\u884c"},"26.3.1 \u7279\u5b9a\u65f6\u95f4\u540e\u6267\u884c"),Object(b.b)("p",null,"\u8fd9\u91cc\u6f14\u793a ",Object(b.b)("inlineCode",{parentName:"p"},"3s")," \u540e\u6267\u884c"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{5}","{5}":!0},'Console.WriteLine("\u5f53\u524d\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n\n// timer \u662f\u5b9a\u65f6\u5668\u7684\u5bf9\u8c61\uff0c\u5305\u542b\u5b9a\u65f6\u5668\u76f8\u5173\u4fe1\u606f\n// count \u8868\u793a\u6267\u884c\u6b21\u6570\uff0c\u8fd9\u91cc\u53ea\u6709\u4e00\u6b21\nSpareTime.DoOnce(3000, (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n});\n')),Object(b.b)("h3",{id:"2632-\u914d\u7f6e\u4efb\u52a1\u4fe1\u606f"},"26.3.2 \u914d\u7f6e\u4efb\u52a1\u4fe1\u606f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{3}","{3}":!0},'SpareTime.DoOnce(3000, (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n}, "jobName", "\u63cf\u8ff0\u4e00\u4e0b\u8fd9\u4e2a\u4efb\u52a1\u662f\u5e72\u4ec0\u4e48\u7684");\n')),Object(b.b)("p",null,Object(b.b)("inlineCode",{parentName:"p"},"jobName")," \u6807\u8bc6\u4efb\u52a1\u7684\u552f\u4e00\u6807\u8bc6\uff0c\u901a\u8fc7\u8fd9\u4e2a\u6807\u8bc6\u53ef\u4ee5\u542f\u52a8\u3001\u6682\u505c\u3001\u9500\u6bc1\u4efb\u52a1\u3002"),Object(b.b)("h3",{id:"2633-\u624b\u52a8\u542f\u52a8\u6267\u884c"},"26.3.3 \u624b\u52a8\u542f\u52a8\u6267\u884c"),Object(b.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4efb\u52a1\u521d\u59cb\u5316\u540e\u5c31\u7acb\u5373\u542f\u52a8\uff0c\u7b49\u5f85\u7b26\u5408\u7684\u65f6\u95f4\u5c31\u6267\u884c\uff0c\u6709\u4e9b\u65f6\u5019\u6211\u4eec\u4ec5\u4ec5\u60f3\u521d\u59cb\u5316\u65f6\u95f4\uff0c\u4e0d\u5e0c\u671b\u7acb\u5373\u6267\u884c\uff0c\u53ea\u9700\u8981\u914d\u7f6e ",Object(b.b)("inlineCode",{parentName:"p"},"startNow")," \u5373\u53ef\uff1a"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{3,6}","{3,6}":!0},'SpareTime.DoOnce(3000, (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n},"jobName", startNow: false);\n\n// \u624b\u52a8\u542f\u52a8\u6267\u884c\nSpareTime.Start("jobName");\n')),Object(b.b)("h3",{id:"2634-\u6a21\u62df\u540e\u53f0\u6267\u884c"},"26.3.4 \u6a21\u62df\u540e\u53f0\u6267\u884c"),Object(b.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5f00\u542f\u65b0\u7ebf\u7a0b\u53bb\u6267\u884c\u4e00\u4e2a\u4efb\u52a1\uff0c\u6bd4\u5982\u53d1\u77ed\u4fe1\uff0c\u53d1\u90ae\u4ef6\uff0c\u65e0\u9700\u914d\u7f6e\u3002"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2}","{2}":!0},"// \u6b64\u65b9\u6cd5\u65e0\u9700\u4e3b\u7ebf\u7a0b\u7b49\u5f85\u5373\u53ef\u8fd4\u56de\uff0c\u53ef\u5927\u5927\u63d0\u9ad8\u6027\u80fd\nSpareTime.DoIt(() => {\n    // \u8fd9\u91cc\u53d1\u9001\u77ed\u4fe1\uff0c\u53d1\u9001\u90ae\u4ef6\u6216\u8bb0\u5f55\u8bbf\u95ee\u8bb0\u5f55\n});\n")),Object(b.b)("p",null,"\u8fd8\u53ef\u4ee5\u6307\u5b9a\u591a\u957f\u65f6\u95f4\u540e\u89e6\u53d1\uff0c\u5efa\u8bae ",Object(b.b)("inlineCode",{parentName:"p"},"10-1000")," \u6beb\u79d2\u4e4b\u95f4\uff1a"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{3}","{3}":!0},"SpareTime.DoIt(() => {\n    // \u53d1\u9001\u77ed\u4fe1\n}, 100);\n")),Object(b.b)("h3",{id:"2635-isparetimeworker-\u65b9\u5f0f"},"26.3.5 ",Object(b.b)("inlineCode",{parentName:"h3"},"ISpareTimeWorker")," \u65b9\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,8}","{1,8}":!0},'public class JobWorker : ISpareTimeWorker\n{\n    /// <summary>\n    /// 3s \u540e\u6267\u884c\n    /// </summary>\n    /// <param name="timer"></param>\n    /// <param name="count"></param>\n    [SpareTime(3000, "jobName", DoOnce = true, StartNow = true)]\n    public void DoSomething(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    }\n}\n')),Object(b.b)("p",null,Object(b.b)("strong",{parentName:"p"},"\u9700\u8981\u5728 ",Object(b.b)("inlineCode",{parentName:"strong"},"Startup.cs")," \u4e2d\u6ce8\u518c ",Object(b.b)("inlineCode",{parentName:"strong"},"services.AddTaskScheduler()"))),Object(b.b)("h2",{id:"264-\u95f4\u9694\u65b9\u5f0f\u4f7f\u7528"},"26.4 \u95f4\u9694\u65b9\u5f0f\u4f7f\u7528"),Object(b.b)("h3",{id:"2641-\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u6267\u884c"},"26.4.1 \u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u6267\u884c"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2}","{2}":!0},'// \u6bcf\u9694 1s \u6267\u884c\nSpareTime.Do(1000, (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n});\n')),Object(b.b)("h3",{id:"2642-\u914d\u7f6e\u4efb\u52a1\u4fe1\u606f"},"26.4.2 \u914d\u7f6e\u4efb\u52a1\u4fe1\u606f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,4}","{1,4}":!0},'SpareTime.Do(1000, (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}, "jobName", "\u8fd9\u662f\u4e00\u4e2a\u8ba1\u65f6\u5668\u4efb\u52a1");\n')),Object(b.b)("h3",{id:"2643-\u624b\u52a8\u542f\u52a8\u6267\u884c"},"26.4.3 \u624b\u52a8\u542f\u52a8\u6267\u884c"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,4,6}","{1,4,6}":!0},'SpareTime.Do(1000, (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}, "jobName", startNow:false);\n\nSpareTime.Start("jobName");\n')),Object(b.b)("h3",{id:"2644-isparetimeworker-\u65b9\u5f0f"},"26.4.4 ",Object(b.b)("inlineCode",{parentName:"h3"},"ISpareTimeWorker")," \u65b9\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,8}","{1,8}":!0},'public class JobWorker : ISpareTimeWorker\n{\n    /// <summary>\n    /// \u6bcf\u9694 3s \u6267\u884c\n    /// </summary>\n    /// <param name="timer"></param>\n    /// <param name="count"></param>\n    [SpareTime(3000, "jobName", StartNow = true)]\n    public void DoSomething(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n}\n')),Object(b.b)("p",null,Object(b.b)("strong",{parentName:"p"},"\u9700\u8981\u5728 ",Object(b.b)("inlineCode",{parentName:"strong"},"Startup.cs")," \u4e2d\u6ce8\u518c ",Object(b.b)("inlineCode",{parentName:"strong"},"services.AddTaskScheduler()"))),Object(b.b)("h2",{id:"265-cron-\u8868\u8fbe\u5f0f\u4f7f\u7528"},"26.5 ",Object(b.b)("inlineCode",{parentName:"h2"},"Cron")," \u8868\u8fbe\u5f0f\u4f7f\u7528"),Object(b.b)("h3",{id:"2651-\u4ec0\u4e48\u662f-cron-\u8868\u8fbe\u5f0f"},"26.5.1 \u4ec0\u4e48\u662f ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f"),Object(b.b)("p",null,"Cron \u8868\u8fbe\u5f0f\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5b57\u7b26\u4e32\u4ee5 ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u6216 ",Object(b.b)("inlineCode",{parentName:"p"},"6")," \u4e2a\u7a7a\u683c\u9694\u5f00\uff0c\u5206\u4e3a 6 \u6216 7 \u4e2a\u57df\uff0c\u6bcf\u4e00\u4e2a\u57df\u4ee3\u8868\u4e00\u4e2a\u542b\u4e49\uff0cCron \u6709\u5982\u4e0b\u4e24\u79cd\u8bed\u6cd5\u683c\u5f0f\uff1a"),Object(b.b)("p",null,"\uff081\uff09 Seconds Minutes Hours DayofMonth Month DayofWeek Year"),Object(b.b)("p",null,"\uff082\uff09Seconds Minutes Hours DayofMonth Month DayofWeek"),Object(b.b)("p",null,"Cron \u4ece\u5de6\u5230\u53f3\uff08\u7528\u7a7a\u683c\u9694\u5f00\uff09\uff1a",Object(b.b)("inlineCode",{parentName:"p"},"\u79d2")," ",Object(b.b)("inlineCode",{parentName:"p"},"\u5206")," ",Object(b.b)("inlineCode",{parentName:"p"},"\u5c0f\u65f6")," ",Object(b.b)("inlineCode",{parentName:"p"},"\u6708\u4efd\u4e2d\u7684\u65e5\u671f")," ",Object(b.b)("inlineCode",{parentName:"p"},"\u6708\u4efd")," ",Object(b.b)("inlineCode",{parentName:"p"},"\u661f\u671f\u4e2d\u7684\u65e5\u671f")," ",Object(b.b)("inlineCode",{parentName:"p"},"\u5e74\u4efd")),Object(b.b)("table",null,Object(b.b)("thead",{parentName:"table"},Object(b.b)("tr",{parentName:"thead"},Object(b.b)("th",{parentName:"tr",align:null},"\u5b57\u6bb5"),Object(b.b)("th",{parentName:"tr",align:null},"\u5141\u8bb8\u503c"),Object(b.b)("th",{parentName:"tr",align:null},"\u5141\u8bb8\u7684\u7279\u6b8a\u5b57\u7b26"))),Object(b.b)("tbody",{parentName:"table"},Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u79d2\uff08Seconds\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0~59")," \u7684\u6574\u6570"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},", - \\* /")," \u56db\u4e2a\u5b57\u7b26")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u5206\uff08Minutes\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0~59")," \u7684\u6574\u6570"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},", - \\* /")," \u56db\u4e2a\u5b57\u7b26")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u5c0f\u65f6\uff08Hours\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0~23")," \u7684\u6574\u6570"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},", - \\* /")," \u56db\u4e2a\u5b57\u7b26")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u65e5\u671f\uff08DayofMonth\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"1~31")," \u7684\u6574\u6570\uff08\u4f46\u662f\u4f60\u9700\u8981\u8003\u8651\u4f60\u6708\u7684\u5929\u6570\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},",- \\* ? / L W C")," \u516b\u4e2a\u5b57\u7b26")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u6708\u4efd\uff08Month\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"1~12")," \u7684\u6574\u6570\u6216\u8005 ",Object(b.b)("inlineCode",{parentName:"td"},"JAN-DEC")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},", - \\* /")," \u56db\u4e2a\u5b57\u7b26")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u661f\u671f\uff08DayofWeek\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"1~7")," \u7684\u6574\u6570\u6216\u8005 ",Object(b.b)("inlineCode",{parentName:"td"},"SUN-SAT \uff081=SUN\uff09")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},", - \\* ? / L C #")," \u516b\u4e2a\u5b57\u7b26")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},"\u5e74(\u53ef\u9009\uff0c\u7559\u7a7a)\uff08Year\uff09"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"1970~2099")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},", - \\* /")," \u56db\u4e2a\u5b57\u7b26")))),Object(b.b)("p",null,"\u6bcf\u4e00\u4e2a\u57df\u90fd\u4f7f\u7528\u6570\u5b57\uff0c\u4f46\u8fd8\u53ef\u4ee5\u51fa\u73b0\u5982\u4e0b\u7279\u6b8a\u5b57\u7b26\uff0c\u5b83\u4eec\u7684\u542b\u4e49\u662f\uff1a"),Object(b.b)("p",null,"\uff081\uff09",Object(b.b)("inlineCode",{parentName:"p"},"_"),"\uff1a\u8868\u793a\u5339\u914d\u8be5\u57df\u7684\u4efb\u610f\u503c\u3002\u5047\u5982\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"Minutes")," \u57df\u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"p"},"\\_"),", \u5373\u8868\u793a\u6bcf\u5206\u949f\u90fd\u4f1a\u89e6\u53d1\u4e8b\u4ef6\u3002"),Object(b.b)("p",null,"\uff082\uff09",Object(b.b)("inlineCode",{parentName:"p"},"?"),"\uff1a\u53ea\u80fd\u7528\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"DayofMonth")," \u548c ",Object(b.b)("inlineCode",{parentName:"p"},"DayofWeek")," \u4e24\u4e2a\u57df\u3002\u5b83\u4e5f\u5339\u914d\u57df\u7684\u4efb\u610f\u503c\uff0c\u4f46\u5b9e\u9645\u4e0d\u4f1a\u3002\u56e0\u4e3a ",Object(b.b)("inlineCode",{parentName:"p"},"DayofMonth")," \u548c ",Object(b.b)("inlineCode",{parentName:"p"},"DayofWeek")," \u4f1a\u76f8\u4e92\u5f71\u54cd\u3002\u4f8b\u5982\u60f3\u5728\u6bcf\u6708\u7684 ",Object(b.b)("inlineCode",{parentName:"p"},"20")," \u65e5\u89e6\u53d1\u8c03\u5ea6\uff0c\u4e0d\u7ba1 ",Object(b.b)("inlineCode",{parentName:"p"},"20")," \u65e5\u5230\u5e95\u662f\u661f\u671f\u51e0\uff0c\u5219\u53ea\u80fd\u4f7f\u7528\u5982\u4e0b\u5199\u6cd5\uff1a ",Object(b.b)("inlineCode",{parentName:"p"},"13 13 15 20 _ ?"),", \u5176\u4e2d\u6700\u540e\u4e00\u4f4d\u53ea\u80fd\u7528",Object(b.b)("inlineCode",{parentName:"p"},"\uff1f"),"\uff0c\u800c\u4e0d\u80fd\u4f7f\u7528","_","\uff0c\u5982\u679c\u4f7f\u7528","*","\u8868\u793a\u4e0d\u7ba1\u661f\u671f\u51e0\u90fd\u4f1a\u89e6\u53d1\uff0c\u5b9e\u9645\u4e0a\u5e76\u4e0d\u662f\u8fd9\u6837\u3002"),Object(b.b)("p",null,"\uff083\uff09",Object(b.b)("inlineCode",{parentName:"p"},"-"),"\uff1a\u8868\u793a\u8303\u56f4\u3002\u4f8b\u5982\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"Minutes")," \u57df\u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"p"},"5-20"),"\uff0c\u8868\u793a\u4ece ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u5206\u5230 ",Object(b.b)("inlineCode",{parentName:"p"},"20")," \u5206\u949f\u6bcf\u5206\u949f\u89e6\u53d1\u4e00\u6b21"),Object(b.b)("p",null,"\uff084\uff09",Object(b.b)("inlineCode",{parentName:"p"},"/"),"\uff1a\u8868\u793a\u8d77\u59cb\u65f6\u95f4\u5f00\u59cb\u89e6\u53d1\uff0c\u7136\u540e\u6bcf\u9694\u56fa\u5b9a\u65f6\u95f4\u89e6\u53d1\u4e00\u6b21\u3002\u4f8b\u5982\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"Minutes")," \u57df\u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"p"},"5/20"),"\uff0c\u5219\u610f\u5473\u7740 ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u5206\u949f\u89e6\u53d1\u4e00\u6b21\uff0c\u800c ",Object(b.b)("inlineCode",{parentName:"p"},"25\uff0c45")," \u7b49\u5206\u522b\u89e6\u53d1\u4e00\u6b21."),Object(b.b)("p",null,"\uff085\uff09",Object(b.b)("inlineCode",{parentName:"p"},","),"\uff1a\u8868\u793a\u5217\u51fa\u679a\u4e3e\u503c\u3002\u4f8b\u5982\uff1a\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"Minutes")," \u57df\u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"p"},"5,20"),"\uff0c\u5219\u610f\u5473\u7740\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u548c ",Object(b.b)("inlineCode",{parentName:"p"},"20")," \u5206\u6bcf\u5206\u949f\u89e6\u53d1\u4e00\u6b21\u3002"),Object(b.b)("p",null,"\uff086\uff09",Object(b.b)("inlineCode",{parentName:"p"},"L"),"\uff1a\u8868\u793a\u6700\u540e\uff0c\u53ea\u80fd\u51fa\u73b0\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"DayofWeek")," \u548c ",Object(b.b)("inlineCode",{parentName:"p"},"DayofMonth")," \u57df\u3002\u5982\u679c\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"DayofWeek")," \u57df\u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"p"},"5L"),",\u610f\u5473\u7740\u5728\u6700\u540e\u7684\u4e00\u4e2a\u661f\u671f\u56db\u89e6\u53d1\u3002"),Object(b.b)("p",null,"\uff087\uff09",Object(b.b)("inlineCode",{parentName:"p"},"W"),"\uff1a\u8868\u793a\u6709\u6548\u5de5\u4f5c\u65e5(\u5468\u4e00\u5230\u5468\u4e94) \u53ea\u80fd\u51fa\u73b0\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"DayofMonth")," \u57df\uff0c\u7cfb\u7edf\u5c06\u5728\u79bb\u6307\u5b9a\u65e5\u671f\u7684\u6700\u8fd1\u7684\u6709\u6548\u5de5\u4f5c\u65e5\u89e6\u53d1\u4e8b\u4ef6\u3002\u4f8b\u5982\uff1a\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"DayofMonth")," \u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"p"},"5W"),"\uff0c\u5982\u679c ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u65e5\u662f\u661f\u671f\u516d\uff0c\u5219\u5c06\u5728\u6700\u8fd1\u7684\u5de5\u4f5c\u65e5\uff1a\u661f\u671f\u4e94\uff0c\u5373 ",Object(b.b)("inlineCode",{parentName:"p"},"4")," \u65e5\u89e6\u53d1\u3002\u5982\u679c ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u65e5\u662f\u661f\u671f\u5929\uff0c\u5219\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"6")," \u65e5(\u5468\u4e00)\u89e6\u53d1\uff1b\u5982\u679c ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u65e5\u5728\u661f\u671f\u4e00\u5230\u661f\u671f\u4e94\u4e2d\u7684\u4e00\u5929\uff0c\u5219\u5c31\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"5")," \u65e5\u89e6\u53d1\u3002\u53e6\u5916\u4e00\u70b9\uff0c",Object(b.b)("inlineCode",{parentName:"p"},"W")," \u7684\u6700\u8fd1\u5bfb\u627e\u4e0d\u4f1a\u8de8\u8fc7\u6708\u4efd \u3002"),Object(b.b)("p",null,"\uff088\uff09",Object(b.b)("inlineCode",{parentName:"p"},"LW"),"\uff1a\u8fd9\u4e24\u4e2a\u5b57\u7b26\u53ef\u4ee5\u8fde\u7528\uff0c\u8868\u793a\u5728\u67d0\u4e2a\u6708\u6700\u540e\u4e00\u4e2a\u5de5\u4f5c\u65e5\uff0c\u5373\u6700\u540e\u4e00\u4e2a\u661f\u671f\u4e94\u3002"),Object(b.b)("p",null,"\uff089\uff09",Object(b.b)("inlineCode",{parentName:"p"},"#"),"\uff1a\u7528\u4e8e\u786e\u5b9a\u6bcf\u4e2a\u6708\u7b2c\u51e0\u4e2a\u661f\u671f\u51e0\uff0c\u53ea\u80fd\u51fa\u73b0\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"DayofMonth")," \u57df\u3002\u4f8b\u5982\u5728 ",Object(b.b)("inlineCode",{parentName:"p"},"4#2"),"\uff0c\u8868\u793a\u67d0\u6708\u7684\u7b2c\u4e8c\u4e2a\u661f\u671f\u4e09\u3002"),Object(b.b)("h3",{id:"2552-\u5e38\u89c1-cron-\u8868\u8fbe\u5f0f"},"25.5.2 \u5e38\u89c1 ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f"),Object(b.b)("table",null,Object(b.b)("thead",{parentName:"table"},Object(b.b)("tr",{parentName:"thead"},Object(b.b)("th",{parentName:"tr",align:null},"\u8868\u8fbe\u5f0f"),Object(b.b)("th",{parentName:"tr",align:null},"\u8868\u8fbe\u5f0f\u4ee3\u8868\u542b\u4e49"),Object(b.b)("th",{parentName:"tr",align:null},"\u683c\u5f0f\u5316"))),Object(b.b)("tbody",{parentName:"table"},Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"*/1 * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0/1 * * * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 * * * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5c0f\u65f6"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 0/1 * * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5c0f\u65f6"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 23 ? * MON-FRI")),Object(b.b)("td",{parentName:"tr",align:null},"\u665a\u4e0a 11:00\uff0c\u5468\u4e00\u81f3\u5468\u4e94"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u79d2"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"*/45 * * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf 45 \u79d2"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"*/5 * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf 5 \u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0/10 * * * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf 10 \u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 */5 * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf 5 \u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"30 11 * * 1-5")),Object(b.b)("td",{parentName:"tr",align:null},"\u5468\u4e00\u81f3\u5468\u4e94\u4e0a\u5348 11:30"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"30 11 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"11:30"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0-10 11 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0a\u5348 11:00 \u81f3 11:10 \u4e4b\u95f4\u7684\u6bcf\u4e00\u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * 3 *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f\uff0c\u53ea\u5728 3 \u6708\u4efd"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * 3,6 *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f\uff0c\u53ea\u5728 3 \u6708\u548c 6 \u6708"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"30 14,16 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 02:30 \u5206\u548c 04:30 \u5206"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"30 6,14,16 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u65e9\u4e0a 06:30\uff0c\u4e0b\u5348 02:30 \u548c 04:30"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"46 9 * * 1")),Object(b.b)("td",{parentName:"tr",align:null},"\u65e9\u4e0a 09:46\uff0c\u53ea\u5728\u661f\u671f\u4e00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"23 12 15 * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 12:23\uff0c\u5728\u672c\u6708\u7684\u7b2c 15 \u5929"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"23 12 * JAN *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 12:23\uff0c\u53ea\u5728 1 \u6708\u4efd"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"23 12 ? JAN *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 12:23\uff0c\u53ea\u5728 1 \u6708\u4efd"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"23 12 * JAN-FEB *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 12:23\uff0c1 \u6708\u81f3 2 \u6708"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"23 12 * JAN-MAR *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 12:23\uff0c1 \u6708\u81f3 3 \u6708"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"23 12 * * SUN")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 12:23\uff0c\u4ec5\u5728\u661f\u671f\u5929"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"*/5 15 * * MON-FRI")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf 5 \u5206\u949f\uff0c\u4e0b\u5348 0:00 \u81f3 03:59\uff0c\u5468\u4e00\u81f3\u5468\u4e94"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * * MON#3")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f\uff0c\u5728\u6708\u7684\u7b2c\u4e09\u4e2a\u661f\u671f\u4e00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * * 4L")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u4e00\u5206\u949f\uff0c\u5728\u672c\u6708\u7684\u6700\u540e\u4e00\u5929"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"*/5 * L JAN *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u6708\u4e00\u6b21\u6bcf\u6708 5 \u5206\u949f\uff0c\u53ea\u5728 1 \u6708\u4efd"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"30 02 14 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348\u5728 02:02:30"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"5-10 * * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f\u7684 5-10 \u79d2"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"5-10 30-35 10-12 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"10:00 \u81f3 12:00 \u4e4b\u95f4\u7684\u6bcf\u5206\u949f 5-10 \u79d2\uff0c\u6bcf\u5c0f\u65f6 30-35 \u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"30 */5 * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f\u7684 30 \u79d2\uff0c\u6bcf\u4e94\u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 30 10-13 ? * WED,FRI")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5c0f\u65f6\u7684 30 \u5206\u949f\uff0c\u4e0b\u5348 10:00 \u81f3 01:00 \u4e4b\u95f4\uff0c\u4ec5\u5728\u5468\u4e09\u548c\u5468\u4e94"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"10 0/5 * * * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5206\u949f\u7684 10 \u79d2\uff0c\u6bcf 05 \u5206\u949f"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 6 1/1 * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e0b\u5348 06:00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 5 0/1 * * ?")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e00\u4e2a\u5c0f\u65f6\u7684 05 \u5206"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.IncludeSeconds"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 L * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u6708\u6700\u540e\u4e00\u5929\u4e0a\u5348 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 L-1 * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u6708\u6700\u540e\u4e00\u5929\u7684\u51cc\u6668 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 3W * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u6708\u7b2c 3 \u4e2a\u5de5\u4f5c\u65e5\u4e0a\u5348 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 LW * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u5728\u6bcf\u6708\u7684\u6700\u540e\u4e00\u4e2a\u5de5\u4f5c\u65e5\uff0c\u4e0a\u5348 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 * * 2L")),Object(b.b)("td",{parentName:"tr",align:null},"\u672c\u6708\u6700\u540e\u4e00\u4e2a\u661f\u671f\u4e8c\u4e0a\u5348 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 * * 6#3")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u6708\u7b2c\u4e09\u4e2a\u661f\u671f\u516d\u4e0a\u5348 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 ? 1 MON#1")),Object(b.b)("td",{parentName:"tr",align:null},"1 \u6708\u7b2c\u4e00\u4e2a\u661f\u671f\u4e00\u4e0a\u5348 00\uff1a00"),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"CronFormat.Standard"))))),Object(b.b)("h3",{id:"2553-\u5728\u7ebf\u751f\u6210-cron-\u8868\u8fbe\u5f0f"},"25.5.3 \u5728\u7ebf\u751f\u6210 ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f"),Object(b.b)("p",null,Object(b.b)("a",{parentName:"p",href:"https://cron.qqe2.com/"},"https://cron.qqe2.com/")),Object(b.b)("h3",{id:"2554-macro-\u6807\u8bc6\u7b26"},"25.5.4 ",Object(b.b)("inlineCode",{parentName:"h3"},"Macro")," \u6807\u8bc6\u7b26"),Object(b.b)("p",null,"\u4e3a\u4e86\u65b9\u4fbf\u5b9a\u4e49 ",Object(b.b)("inlineCode",{parentName:"p"},"Cron")," \u8868\u8fbe\u5f0f\uff0c",Object(b.b)("inlineCode",{parentName:"p"},"Furion")," \u6846\u67b6\u4e5f\u63d0\u4f9b\u4e86\u975e\u5e38\u65b9\u4fbf\u7684\u5360\u4f4d\u7b26\u5b9e\u73b0\u5e38\u7528\u7684\u65f6\u95f4\u683c\u5f0f\uff1a"),Object(b.b)("table",null,Object(b.b)("thead",{parentName:"table"},Object(b.b)("tr",{parentName:"thead"},Object(b.b)("th",{parentName:"tr",align:null},"\u5360\u4f4d\u7b26"),Object(b.b)("th",{parentName:"tr",align:null},"\u5bf9\u5e94\u8868\u8fbe\u5f0f"),Object(b.b)("th",{parentName:"tr",align:null},"\u5360\u4f4d\u7b26\u4ee3\u8868\u542b\u4e49"))),Object(b.b)("tbody",{parentName:"table"},Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@every_second")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u4e00\u79d2\u949f\u8dd1\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@every_minute")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"* * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u5728\u5206\u949f\u5f00\u59cb\u65f6\u6bcf\u5206\u949f\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@hourly")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 * * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u5728\u5c0f\u65f6\u5f00\u59cb\u65f6\u6bcf\u5c0f\u65f6\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@daily")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5929\u5348\u591c\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@midnight")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 * * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5929\u5348\u591c\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@weekly")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 * * 0")),Object(b.b)("td",{parentName:"tr",align:null},"\u5468\u65e5\u4e0a\u5348\u5348\u591c\u6bcf\u5468\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@monthly")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 1 * *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u6708\u5728\u6bcf\u6708\u7b2c\u4e00\u5929\u7684\u5348\u591c\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@yearly")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 1 1 *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5e74 1 \u6708 1 \u65e5\u5348\u591c\u8fd0\u884c\u4e00\u6b21")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"@annually")),Object(b.b)("td",{parentName:"tr",align:null},Object(b.b)("inlineCode",{parentName:"td"},"0 0 1 1 *")),Object(b.b)("td",{parentName:"tr",align:null},"\u6bcf\u5e74 1 \u6708 1 \u65e5\u5348\u591c\u8fd0\u884c\u4e00\u6b21")))),Object(b.b)("h3",{id:"2555-\u4f7f\u7528-cron-\u8868\u8fbe\u5f0f"},"25.5.5 \u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2,5}","{2,5}":!0},'// \u6bcf\u9694 1s \u6267\u884c\nSpareTime.Do("* * * * * *", (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}, cronFormat: CronFormat.IncludeSeconds);\n')),Object(b.b)("div",{className:"admonition admonition-important alert alert--info"},Object(b.b)("div",{parentName:"div",className:"admonition-heading"},Object(b.b)("h5",{parentName:"div"},Object(b.b)("span",{parentName:"h5",className:"admonition-icon"},Object(b.b)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},Object(b.b)("path",{parentName:"svg",fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),"\u5173\u4e8e CronFormat")),Object(b.b)("div",{parentName:"div",className:"admonition-content"},Object(b.b)("p",{parentName:"div"},"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(b.b)("inlineCode",{parentName:"p"},"Furion")," \u6846\u67b6\u672a\u542f\u7528\u5bf9 ",Object(b.b)("inlineCode",{parentName:"p"},"\u79d2")," \u7684\u652f\u6301\uff0c\u5982\u9700\u5f00\u542f\uff0c\u5219\u8bbe\u7f6e ",Object(b.b)("inlineCode",{parentName:"p"},"cronFormat: CronFormat.IncludeSeconds")," \u5373\u53ef\u3002\u9ed8\u8ba4\u503c\u662f ",Object(b.b)("inlineCode",{parentName:"p"},"cronFormat: CronFormat.Standard")))),Object(b.b)("h3",{id:"2556-\u4f7f\u7528-macro-\u5360\u4f4d\u7b26"},"25.5.6 \u4f7f\u7528 ",Object(b.b)("inlineCode",{parentName:"h3"},"Macro")," \u5360\u4f4d\u7b26"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2}","{2}":!0},'// \u6bcf\u9694 1s \u6267\u884c\nSpareTime.Do("@every_second", (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n});\n')),Object(b.b)("h3",{id:"2557-\u914d\u7f6e\u4efb\u52a1\u4fe1\u606f"},"25.5.7 \u914d\u7f6e\u4efb\u52a1\u4fe1\u606f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{4}","{4}":!0},'SpareTime.Do("* * * * *", (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}, "cronName", "\u6bcf\u5206\u949f\u6267\u884c\u4e00\u6b21");\n')),Object(b.b)("h3",{id:"2558-\u624b\u52a8\u542f\u52a8\u6267\u884c"},"25.5.8 \u624b\u52a8\u542f\u52a8\u6267\u884c"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{4,6}","{4,6}":!0},'SpareTime.Do("* * * * *", (timer, count) => {\n    Console.WriteLine("\u73b0\u5728\u65f6\u95f4\uff1a" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}, "cronName", "\u6bcf\u5206\u949f\u6267\u884c\u4e00\u6b21", startNow: false);\n\nSpareTime.Start("cronName");\n')),Object(b.b)("h3",{id:"2659-isparetimeworker-\u65b9\u5f0f"},"26.5.9 ",Object(b.b)("inlineCode",{parentName:"h3"},"ISpareTimeWorker")," \u65b9\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,8}","{1,8}":!0},'public class JobWorker : ISpareTimeWorker\n{\n    /// <summary>\n    /// \u6bcf\u5206\u949f\u6267\u884c\n    /// </summary>\n    /// <param name="timer"></param>\n    /// <param name="count"></param>\n    [SpareTime("* * * * *", "jobName", StartNow = true)]\n    public void DoSomething(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n}\n')),Object(b.b)("h2",{id:"266-\u81ea\u5b9a\u4e49\u4e0b\u6b21\u6267\u884c\u65f6\u95f4"},"26.6 \u81ea\u5b9a\u4e49\u4e0b\u6b21\u6267\u884c\u65f6\u95f4"),Object(b.b)("p",null,"\u6709\u4e9b\u65f6\u5019\u6211\u4eec\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u4e1a\u52a1\u903b\u8f91\uff0c\u6bd4\u5982\u6570\u636e\u5e93\u67e5\u8be2\u7b49\u64cd\u4f5c\u8fd4\u56de\u4e0b\u4e00\u6b21\u6267\u884c\u65f6\u95f4\uff0c\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u65b9\u5f0f\u3002"),Object(b.b)("h3",{id:"2661-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u95f4\u9694\u65b9\u5f0f"},"26.6.1 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u95f4\u9694\u65b9\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2,4-5,7}","{2,4-5,7}":!0},'SpareTime.Do(()=>{\n    // \u8fd9\u91cc\u53ef\u4ee5\u67e5\u8be2\u6570\u636e\u5e93\u6216\u8fdb\u884c\u6216\u8fdb\u884c\u4efb\u4f55\u4e1a\u52a1\u903b\u8f91\n\n    if(\u7b26\u5408\u903b\u8f91){\n        return 1000; // \u6bcf\u79d2\u6267\u884c\n    }\n    else return -1; // \u4e0d\u7b26\u5408\u903b\u8f91\u53d6\u6d88\u4efb\u52a1\n},\n(timer,count)=>{\n    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n});\n')),Object(b.b)("div",{className:"admonition admonition-important alert alert--info"},Object(b.b)("div",{parentName:"div",className:"admonition-heading"},Object(b.b)("h5",{parentName:"div"},Object(b.b)("span",{parentName:"h5",className:"admonition-icon"},Object(b.b)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},Object(b.b)("path",{parentName:"svg",fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),"\u914d\u7f6e\u662f\u5426\u6301\u7eed\u68c0\u67e5")),Object(b.b)("div",{parentName:"div",className:"admonition-content"},Object(b.b)("p",{parentName:"div"},"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8be5\u81ea\u5b9a\u4e49\u4f1a\u5728\u8fd4\u56de ",Object(b.b)("inlineCode",{parentName:"p"},"\u5c0f\u4e8e\u6216\u7b49\u4e8e0")," \u65f6\u7ec8\u6b62\u4efb\u52a1\u7684\u6267\u884c\u3002\u4f46\u662f\u6211\u4eec\u5e0c\u671b\u8be5\u4efb\u52a1\u4e0d\u8981\u7ec8\u6b62\uff0c\u53ea\u8981\u7b26\u5408\u6761\u4ef6\u90fd\u4e00\u76f4\u6267\u884c\uff0c\u53ea\u9700\u8981\u914d\u7f6e ",Object(b.b)("inlineCode",{parentName:"p"},"cancelInNoneNextTime: false")," \u5373\u53ef"))),Object(b.b)("h3",{id:"2662-\u9ad8\u7ea7\u81ea\u5b9a\u4e49-cron-\u8868\u8fbe\u5f0f"},"26.6.2 \u9ad8\u7ea7\u81ea\u5b9a\u4e49 ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2,4-5,7}","{2,4-5,7}":!0},'SpareTime.Do(()=>{\n    // \u8fd9\u91cc\u53ef\u4ee5\u67e5\u8be2\u6570\u636e\u5e93\u6216\u8fdb\u884c\u6216\u8fdb\u884c\u4efb\u4f55\u4e1a\u52a1\u903b\u8f91\n\n    if(\u7b26\u5408\u903b\u8f91){\n        return DateTime.Now.AddMinutes(10);  // \u5341\u5206\u949f\u540e\u518d\u6267\u884c\n    }\n    else return null; // \u4e0d\u7b26\u5408\u903b\u8f91\u53d6\u6d88\u4efb\u52a1\n},\n(timer,count) => {\n    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n});\n')),Object(b.b)("div",{className:"admonition admonition-important alert alert--info"},Object(b.b)("div",{parentName:"div",className:"admonition-heading"},Object(b.b)("h5",{parentName:"div"},Object(b.b)("span",{parentName:"h5",className:"admonition-icon"},Object(b.b)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},Object(b.b)("path",{parentName:"svg",fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),"\u914d\u7f6e\u662f\u5426\u6301\u7eed\u68c0\u67e5")),Object(b.b)("div",{parentName:"div",className:"admonition-content"},Object(b.b)("p",{parentName:"div"},"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8be5\u81ea\u5b9a\u4e49\u4f1a\u5728\u8fd4\u56de ",Object(b.b)("inlineCode",{parentName:"p"},"null")," \u65f6\u7ec8\u6b62\u4efb\u52a1\u7684\u6267\u884c\u3002\u4f46\u662f\u6211\u4eec\u5e0c\u671b\u8be5\u4efb\u52a1\u4e0d\u8981\u7ec8\u6b62\uff0c\u53ea\u8981\u7b26\u5408\u6761\u4ef6\u90fd\u4e00\u76f4\u6267\u884c\uff0c\u53ea\u9700\u8981\u914d\u7f6e ",Object(b.b)("inlineCode",{parentName:"p"},"cancelInNoneNextTime: false")," \u5373\u53ef\uff0c\u5982\uff1a"),Object(b.b)("pre",{parentName:"div"},Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{2,4-5,7,12}","{2,4-5,7,12}":!0},'SpareTime.Do(()=>{\n    // \u8fd9\u91cc\u53ef\u4ee5\u67e5\u8be2\u6570\u636e\u5e93\u6216\u8fdb\u884c\u6216\u8fdb\u884c\u4efb\u4f55\u4e1a\u52a1\u903b\u8f91\n\n    if(\u7b26\u5408\u903b\u8f91){\n        return DateTime.Now.AddMinutes(10);  // \u5341\u5206\u949f\u540e\u518d\u6267\u884c\n    }\n    else return null; // \u4e0d\u7b26\u5408\u903b\u8f91\u7ee7\u7eed\u68c0\u67e5\n},\n(timer,count) => {\n    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}, cancelInNoneNextTime: false);\n')))),Object(b.b)("h2",{id:"267-isparetimeworker-\u8bf4\u660e"},"26.7 ",Object(b.b)("inlineCode",{parentName:"h2"},"ISpareTimeWorker")," \u8bf4\u660e"),Object(b.b)("p",null,"\u9664\u4e86\u4e0a\u9762\u7684 ",Object(b.b)("inlineCode",{parentName:"p"},"SpareTime")," \u9759\u6001\u7c7b\u65b9\u5f0f\uff0c",Object(b.b)("inlineCode",{parentName:"p"},"Furion")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86 ",Object(b.b)("inlineCode",{parentName:"p"},"ISpareTimeWorker")," \u65b9\u5f0f\uff0c\u4f7f\u7528\u8be5\u65b9\u5f0f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u81ea\u5b9a\u4e49\u4e00\u4e2a",Object(b.b)("strong",{parentName:"p"},"\u516c\u5f00\u4e14\u975e\u62bd\u8c61\u975e\u9759\u6001"),"\u7c7b\u5e76\u5b9e\u73b0 ",Object(b.b)("inlineCode",{parentName:"p"},"ISpareTimeWorker")," \u5373\u53ef\u3002"),Object(b.b)("p",null,"\u5728\u8be5\u7c7b\u4e2d\u5b9a\u4e49\u7684\u4efb\u52a1\u65b9\u6cd5\u9700\u6ee1\u8db3\u4ee5\u4e0b\u89c4\u5219\uff1a"),Object(b.b)("ul",null,Object(b.b)("li",{parentName:"ul"},"\u5fc5\u987b\u662f",Object(b.b)("strong",{parentName:"li"},"\u516c\u5f00\u4e14\u5b9e\u4f8b\u65b9\u6cd5")),Object(b.b)("li",{parentName:"ul"},"\u8be5\u65b9\u6cd5\u5fc5\u987b\u8fd4\u56de ",Object(b.b)("inlineCode",{parentName:"li"},"void")," \u4e14\u63d0\u4f9b ",Object(b.b)("inlineCode",{parentName:"li"},"SpareTimer")," \u548c ",Object(b.b)("inlineCode",{parentName:"li"},"long")," \u4e24\u4e2a\u53c2\u6570"),Object(b.b)("li",{parentName:"ul"},"\u5fc5\u987b\u8d34\u6709 ",Object(b.b)("inlineCode",{parentName:"li"},"[SpareTime]")," \u7279\u6027")),Object(b.b)("p",null,"\u5982\uff1a"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,4-5,12-13,20-21,28-30,37-38}","{1,4-5,12-13,20-21,28-30,37-38}":!0},'public class JobWorker : ISpareTimeWorker\n{\n    // \u6bcf\u4e2a\u4e00\u79d2\u6267\u884c\uff0c\u4e14\u7acb\u5373\u542f\u52a8\n    [SpareTime(1000, "jobName1", StartNow = true)]\n    public void DoSomething1(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n\n    // \u6bcf\u5206\u949f\u6267\u884c\uff0c\u4e14\u7acb\u5373\u542f\u52a8\n    [SpareTime("* * * * *", "jobName2", StartNow = true)]\n    public void DoSomething2(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n\n    // \u6bcf\u79d2\u6267\u884c\uff0c\u4e14\u7b49\u5f85\u542f\u52a8\n    [SpareTime("* * * * * *", "jobName3",CronFormat = CronFormat.IncludeSeconds, StartNow = false)]\n    public void DoSomething3(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n\n    // \u6bcf\u79d2\u6267\u884c\u4e00\u6b21\uff0c\u6bcf\u5206\u949f\u4e5f\u6267\u884c\u4e00\u6b21\n    [SpareTime(1000, "jobName4", StartNow = true)]\n    [SpareTime("* * * * *", "jobName5", StartNow = true)]\n    public void DoSomething4(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n\n    // \u53ea\u6267\u884c\u4e00\u6b21\n    [SpareTime(1000, "jobName4", StartNow = true, DoOnce = true)]\n    public void DoSomething5(SpareTimer timer, long count)\n    {\n        Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n        Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n    }\n}\n')),Object(b.b)("h3",{id:"2671-sparetime-\u7279\u6027"},"26.7.1 ",Object(b.b)("inlineCode",{parentName:"h3"},"[SpareTime]")," \u7279\u6027"),Object(b.b)("p",null,Object(b.b)("inlineCode",{parentName:"p"},"[SpareTime]")," \u652f\u6301\u4ee5\u4e0b\u914d\u7f6e\u5c5e\u6027"),Object(b.b)("ul",null,Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"Interval"),"\uff1a\u95f4\u9694\u65f6\u95f4, ",Object(b.b)("inlineCode",{parentName:"li"},"double")," \u7c7b\u578b"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"CronExpression"),"\uff1a",Object(b.b)("inlineCode",{parentName:"li"},"Cron")," \u8868\u8fbe\u5f0f\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"string")," \u7c7b\u578b"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"WorkerName"),"\uff1a\u4efb\u52a1\u552f\u4e00\u6807\u8bc6\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"string")," \u7c7b\u578b\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"\u5fc5\u586b")),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"Description"),"\uff1a\u4efb\u52a1\u63cf\u8ff0\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"string")," \u7c7b\u578b"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"DoOnce"),"\uff1a\u662f\u5426\u53ea\u6267\u884c\u4e00\u6b21\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"bool")," \u7c7b\u578b\uff0c\u9ed8\u8ba4 ",Object(b.b)("inlineCode",{parentName:"li"},"false")),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"StartNow"),"\uff1a\u662f\u5426\u7acb\u5373\u542f\u52a8\uff0c\u9ed8\u8ba4 ",Object(b.b)("inlineCode",{parentName:"li"},"false")),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"CronFormat"),"\uff1a",Object(b.b)("inlineCode",{parentName:"li"},"Cron")," \u8868\u8fbe\u5f0f\u683c\u5f0f\u5316\u65b9\u5f0f\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"CronFormat")," \u679a\u4e3e\u7c7b\u578b\uff0c\u9ed8\u8ba4 ",Object(b.b)("inlineCode",{parentName:"li"},"CronFormat.Standard")),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"ExecuteType"),"\uff1a\u914d\u7f6e\u4efb\u52a1\u6267\u884c\u65b9\u5f0f\uff0c",Object(b.b)("inlineCode",{parentName:"li"},"SpareTimeExecuteTypes")," \u679a\u4e3e\u7c7b\u578b\uff0c\u9ed8\u8ba4 ",Object(b.b)("inlineCode",{parentName:"li"},"SpareTimeExecuteTypes.Parallel"))),Object(b.b)("h2",{id:"268-sparetime-\u9759\u6001\u7c7b"},"26.8 ",Object(b.b)("inlineCode",{parentName:"h2"},"SpareTime")," \u9759\u6001\u7c7b"),Object(b.b)("p",null,Object(b.b)("inlineCode",{parentName:"p"},"SpareTime")," \u9759\u6001\u7c7b\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u65b9\u4fbf\u521d\u59cb\u5316\u548c\u7ba1\u7406\u4efb\u52a1"),Object(b.b)("h3",{id:"2681-\u521d\u59cb\u5316\u4efb\u52a1"},"26.8.1 \u521d\u59cb\u5316\u4efb\u52a1"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},"// \u5f00\u542f\u95f4\u9694\u4efb\u52a1\nSpareTime.Do(interval, [options]);\n\n// \u5f00\u542f Cron \u8868\u8fbe\u5f0f\u4efb\u52a1\nSpareTime.Do(expression, [options]);\n\n// \u53ea\u6267\u884c\u4e00\u6b21\u4efb\u52a1\nSpareTime.DoOnce(interval, [options]);\n\n// \u5b9e\u73b0\u81ea\u5b9a\u4e49\u4efb\u52a1\nSpareTime.Do(()=>{\n    return DateTime.Now.AddMinutes(10);\n},[options]);\n")),Object(b.b)("h3",{id:"2682-\u5b9e\u73b0\u540e\u53f0\u6267\u884c"},"26.8.2 \u5b9e\u73b0\u540e\u53f0\u6267\u884c"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},"// \u5b9e\u73b0\u540e\u53f0\u6267\u884c\nSpareTime.DoIt(()=>{});\n")),Object(b.b)("h3",{id:"2683-\u5f00\u59cb\u4e00\u4e2a\u4efb\u52a1"},"26.8.3 \u5f00\u59cb\u4e00\u4e2a\u4efb\u52a1"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},'SpareTime.Start("\u4efb\u52a1\u6807\u8bc6");\n')),Object(b.b)("h3",{id:"2684-\u6682\u505c\u4e00\u4e2a\u4efb\u52a1"},"26.8.4 \u6682\u505c\u4e00\u4e2a\u4efb\u52a1"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},'SpareTime.Stop("\u4efb\u52a1\u6807\u8bc6");\n// \u8fd8\u53ef\u4ee5\u6807\u8bb0\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u5931\u8d25\nSpareTime.Stop("\u4efb\u52a1\u6807\u8bc6", true);\n')),Object(b.b)("h3",{id:"2685-\u53d6\u6d88\u4e00\u4e2a\u4efb\u52a1"},"26.8.5 \u53d6\u6d88\u4e00\u4e2a\u4efb\u52a1"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},'SpareTime.Cancel("\u4efb\u52a1\u540d\u79f0");\n')),Object(b.b)("h3",{id:"2686-\u9500\u6bc1\u6240\u6709\u4efb\u52a1"},"26.8.6 \u9500\u6bc1\u6240\u6709\u4efb\u52a1"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},"SpareTime.Dispose();\n")),Object(b.b)("h3",{id:"2687-\u83b7\u53d6\u6240\u6709\u4efb\u52a1"},"26.8.7 \u83b7\u53d6\u6240\u6709\u4efb\u52a1"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},"var workers = SpareTime.GetWorkers();\n")),Object(b.b)("h3",{id:"2688-\u89e3\u6790-cron-\u8868\u8fbe\u5f0f"},"26.8.8 \u89e3\u6790 ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs"},'var nextTime = SpareTime.GetCronNextOccurrence("* * * * *");\n')),Object(b.b)("h2",{id:"269-\u5e76\u884c\u548c\u4e32\u884c\u6267\u884c\u65b9\u5f0f"},"26.9 ",Object(b.b)("inlineCode",{parentName:"h2"},"\u5e76\u884c"),"\u548c",Object(b.b)("inlineCode",{parentName:"h2"},"\u4e32\u884c"),"\u6267\u884c\u65b9\u5f0f"),Object(b.b)("p",null,Object(b.b)("inlineCode",{parentName:"p"},"Furion")," \u6846\u67b6\u63d0\u4f9b\u4e86\u4efb\u52a1\u4e24\u79cd\u6267\u884c\u65b9\u5f0f ",Object(b.b)("inlineCode",{parentName:"p"},"\u5e76\u884c")," \u548c ",Object(b.b)("inlineCode",{parentName:"p"},"\u4e32\u884c"),"\uff1a"),Object(b.b)("ul",null,Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"\u5e76\u884c"),"\uff1a\u65e0\u9700\u7b49\u5f85\u4e0a\u4e00\u6b21\u4efb\u52a1\u5b8c\u6210\uff0c",Object(b.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"\u4e32\u884c"),"\uff1a\u9700\u7b49\u5f85\u4e0a\u4e00\u6b21\u4efb\u52a1\u5b8c\u6210")),Object(b.b)("h3",{id:"2691-sparetime-\u9759\u6001\u65b9\u5f0f\u6307\u5b9a"},"26.9.1 ",Object(b.b)("inlineCode",{parentName:"h3"},"SpareTime")," \u9759\u6001\u65b9\u5f0f\u6307\u5b9a"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{3,5}","{3,5}":!0},'SpareTime.Do(1000, (t, i) =>\n{\n    Thread.Sleep(5000); // \u6a21\u62df\u6267\u884c\u8017\u65f6\u4efb\u52a1\n    Console.WriteLine($"{t.WorkerName} -{t.Description} - {DateTime.Now:yyyy-MM-dd HH:mm:ss} - {i}");\n}, "serialName", "\u6a21\u62df\u4e32\u884c\u4efb\u52a1", executeType: SpareTimeExecuteTypes.Serial);\n')),Object(b.b)("h3",{id:"2692-isparetimeworker-\u65b9\u5f0f"},"26.9.2 ",Object(b.b)("inlineCode",{parentName:"h3"},"ISpareTimeWorker")," \u65b9\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1}","{1}":!0},'[SpareTime(1000, "jobName1", StartNow = true, ExecuteType = SpareTimeExecuteTypes.Serial)]\npublic void DoSomething1(SpareTimer timer, long count)\n{\n    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));\n    Console.WriteLine($"\u4e00\u5171\u6267\u884c\u4e86\uff1a{count} \u6b21");\n}\n')),Object(b.b)("h2",{id:"2610-\u4efb\u52a1\u5f02\u5e38\u5904\u7406"},"26.10 \u4efb\u52a1\u5f02\u5e38\u5904\u7406"),Object(b.b)("p",null,"\u6709\u4e9b\u65f6\u5019\u6211\u4eec\u53ef\u80fd\u5728\u6267\u884c\u4efb\u52a1\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u5f02\u5e38\uff0c",Object(b.b)("inlineCode",{parentName:"p"},"Furion")," \u4e5f\u63d0\u4f9b\u4e86\u5c5e\u6027\u5224\u65ad\u662f\u5426\u6709\u5f02\u5e38\u548c\u5f02\u5e38\u4fe1\u606f\uff0c\u65b9\u4fbf\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\uff0c\u5982\uff1a"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{4-7,11}","{4-7,11}":!0},'SpareTime.Do(1000, (t, c) =>\n{\n    // \u5224\u65ad\u662f\u5426\u6709\u5f02\u5e38\n    if (t.Exception.Any())\n    {\n        Console.WriteLine(t.Exception.Values.LastOrDefault()?.Message);\n    }\n    // \u6267\u884c\u7b2c\u4e09\u6b21\u629b\u5f02\u5e38\n    if (c > 2)\n    {\n        throw Oops.Oh("\u629b\u5f02\u5e38" + c);\n    }\n    else\n    {\n        Console.WriteLine($"{t.WorkerName} -{t.Description} - {DateTime.Now:yyyy-MM-dd HH:mm:ss} - {c}");\n    }\n}, "exceptionJob");\n')),Object(b.b)("div",{className:"admonition admonition-warning alert alert--danger"},Object(b.b)("div",{parentName:"div",className:"admonition-heading"},Object(b.b)("h5",{parentName:"div"},Object(b.b)("span",{parentName:"h5",className:"admonition-icon"},Object(b.b)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"},Object(b.b)("path",{parentName:"svg",fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"}))),"\u7279\u522b\u8bf4\u660e")),Object(b.b)("div",{parentName:"div",className:"admonition-content"},Object(b.b)("p",{parentName:"div"},"\u5982\u679c\u4e00\u4e2a\u4efb\u52a1\u9519\u8bef\u6b21\u6570\u8fbe ",Object(b.b)("inlineCode",{parentName:"p"},"10\u6b21")," \u5219\u4efb\u52a1\u5c06\u81ea\u52a8\u505c\u6b62\uff0c\u5e76\u6807\u8bb0\u4efb\u52a1\u72b6\u6001\u4e3a ",Object(b.b)("inlineCode",{parentName:"p"},"Failed"),"\u3002"))),Object(b.b)("h2",{id:"2611-\u5982\u4f55\u5728\u4efb\u52a1\u4e2d\u89e3\u6790\u5bf9\u8c61"},"26.11 \u5982\u4f55\u5728\u4efb\u52a1\u4e2d\u89e3\u6790\u5bf9\u8c61"),Object(b.b)("p",null,"\u6709\u4e9b\u65f6\u5019\u6211\u4eec\u9700\u8981\u5728\u4efb\u52a1\u4e2d\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u6216\u89e3\u6790\u670d\u52a1\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u53ea\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4f5c\u7528\u57df\u5373\u53ef"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{1,3}","{1,3}":!0},'var scopeFactory = App.GetService<IServiceScopeFactory>();\n\nSpareTime.Do(1000, (timer,count) => {\n    using (var scope = scopeFactory.CreateScope())\n    {\n        var services = scope.ServiceProvider;\n\n        // \u83b7\u53d6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n        var dbContext = Db.GetDbContext(services);\n\n        // \u83b7\u53d6\u4ed3\u50a8\n        var respository = Db.GetRepository<Person>(services);\n\n        // \u89e3\u6790\u5176\u4ed6\u670d\u52a1\n        var otherService = services.GetService<XXX>();\n        var otherService2 = App.GetService<XXX>(services);\n    }\n\n}, "\u4efb\u52a1\u6807\u8bc6");\n')),Object(b.b)("h2",{id:"2612-\u5728-backgroundservice-\u4e2d\u4f7f\u7528"},"26.12 \u5728 ",Object(b.b)("inlineCode",{parentName:"h2"},"BackgroundService")," \u4e2d\u4f7f\u7528"),Object(b.b)("p",null,Object(b.b)("inlineCode",{parentName:"p"},"BackgroundService")," \u662f ",Object(b.b)("inlineCode",{parentName:"p"},".NET Core 3")," \u4e4b\u540e\u63d0\u4f9b\u7684\u8f7b\u91cf\u7ea7\u540e\u53f0\u4efb\u52a1\uff0c\u540c\u65f6\u53ef\u4ee5\u53d1\u5e03\u5230 ",Object(b.b)("inlineCode",{parentName:"p"},"Windows")," \u670d\u52a1\u548c ",Object(b.b)("inlineCode",{parentName:"p"},"Linux")," \u5b88\u62a4\u8fdb\u7a0b\u4e2d\u3002"),Object(b.b)("h3",{id:"26121-\u95f4\u9694\u6267\u884c\u65b9\u5f0f"},"26.12.1 \u95f4\u9694\u6267\u884c\u65b9\u5f0f"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{23-27}","{23-27}":!0},'using Furion.TaskScheduler;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Logging;\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace WorkerService1\n{\n    public class Worker : BackgroundService\n    {\n        private readonly ILogger<Worker> _logger;\n\n        public Worker(ILogger<Worker> logger)\n        {\n            _logger = logger;\n        }\n\n        protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n        {\n            while (!stoppingToken.IsCancellationRequested)\n            {\n                // \u95f4\u9694\u6267\u884c\u4efb\u52a1\n                await SpareTime.DoAsync(1000, () =>\n                {\n                    _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);\n                }, stoppingToken);\n            }\n        }\n    }\n}\n')),Object(b.b)("h3",{id:"26122-cron-\u8868\u8fbe\u5f0f\u6267\u884c\u65b9\u5f0f\uff0c"},"26.12.2 ",Object(b.b)("inlineCode",{parentName:"h3"},"Cron")," \u8868\u8fbe\u5f0f\u6267\u884c\u65b9\u5f0f\uff0c"),Object(b.b)("pre",null,Object(b.b)("code",{parentName:"pre",className:"language-cs",metastring:"{23-27}","{23-27}":!0},'using Furion.TaskScheduler;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Logging;\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace WorkerService1\n{\n    public class Worker : BackgroundService\n    {\n        private readonly ILogger<Worker> _logger;\n\n        public Worker(ILogger<Worker> logger)\n        {\n            _logger = logger;\n        }\n\n        protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n        {\n            while (!stoppingToken.IsCancellationRequested)\n            {\n                // \u6267\u884c Cron \u8868\u8fbe\u5f0f\u4efb\u52a1\n                await SpareTime.DoAsync("*/5 * * * * *", () =>\n                {\n                    _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);\n                }, stoppingToken, CronFormat.IncludeSeconds);\n            }\n        }\n    }\n}\n')),Object(b.b)("h2",{id:"2613-\u53cd\u9988\u4e0e\u5efa\u8bae"},"26.13 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(b.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(b.b)("div",{parentName:"div",className:"admonition-heading"},Object(b.b)("h5",{parentName:"div"},Object(b.b)("span",{parentName:"h5",className:"admonition-icon"},Object(b.b)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},Object(b.b)("path",{parentName:"svg",fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"}))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(b.b)("div",{parentName:"div",className:"admonition-content"},Object(b.b)("p",{parentName:"div"},"\u7ed9 Furion \u63d0 ",Object(b.b)("a",{parentName:"p",href:"https://gitee.com/dotnetchina/Furion/issues/new?issue"},"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]);