"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[9590],{1133:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>d,default:()=>u,frontMatter:()=>t,metadata:()=>o,toc:()=>c});var s=r(5893),i=r(1151);const t={id:"schedular",title:"17. Schedular \u9759\u6001\u7c7b",sidebar_label:"17. Schedular \u9759\u6001\u7c7b"},d=void 0,o={id:"global/schedular",title:"17. Schedular \u9759\u6001\u7c7b",description:"\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 Furion 4.8.0 + \u7248\u672c\u4f7f\u7528\u3002",source:"@site/docs/global/schedular.mdx",sourceDirName:"global",slug:"/global/schedular",permalink:"/docs/global/schedular",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/global/schedular.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1699259946,formattedLastUpdatedAt:"Nov 6, 2023",frontMatter:{id:"schedular",title:"17. Schedular \u9759\u6001\u7c7b",sidebar_label:"17. Schedular \u9759\u6001\u7c7b"},sidebar:"global",previous:{title:"16. Log \u9759\u6001\u7c7b",permalink:"/docs/global/log"},next:{title:"18. TaskQueued \u9759\u6001\u7c7b",permalink:"/docs/global/taskqueued"}},a={},c=[{value:"17.1 \u542f\u52a8\u8c03\u5ea6\u4f5c\u4e1a\u670d\u52a1",id:"171-\u542f\u52a8\u8c03\u5ea6\u4f5c\u4e1a\u670d\u52a1",level:2},{value:"17.2 \u83b7\u53d6\u4f5c\u4e1a\u8c03\u5ea6\u8ba1\u5212\u5de5\u5382",id:"172-\u83b7\u53d6\u4f5c\u4e1a\u8c03\u5ea6\u8ba1\u5212\u5de5\u5382",level:2},{value:"17.3 \u83b7\u53d6\u4f5c\u4e1a",id:"173-\u83b7\u53d6\u4f5c\u4e1a",level:2},{value:"17.4 \u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e",id:"174-\u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e",level:2},{value:"17.5 \u53cd\u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e",id:"175-\u53cd\u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e",level:2}];function l(e){const n={admonition:"admonition",code:"code",h2:"h2",mdxAdmonitionTitle:"mdxAdmonitionTitle",p:"p",pre:"pre",strong:"strong",...(0,i.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 4.8.0 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"171-\u542f\u52a8\u8c03\u5ea6\u4f5c\u4e1a\u670d\u52a1",children:"17.1 \u542f\u52a8\u8c03\u5ea6\u4f5c\u4e1a\u670d\u52a1"}),"\n",(0,s.jsxs)(n.p,{children:["\u8be5\u529f\u80fd ",(0,s.jsx)(n.strong,{children:"\u5efa\u8bae"})," \u4ec5\u9650\u4e0d\u80fd\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"services.AddXXX"})," \u65b9\u5f0f\u4f7f\u7528\uff0c\u6bd4\u5982\u63a7\u5236\u53f0\uff0c",(0,s.jsx)(n.code,{children:"Winfrom/WPF"})," \u7b49\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3}",children:"IDisposable dispose = ScheduleServe.Run(options =>\r\n{\r\n options.AddJob(Triggers.Secondly());\r\n});\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u79cd\u65b9\u5f0f\u6709\u4e00\u4e2a\u9690\u85cf\u7684\u5de8\u5927\u9690\u85cf \u201c\u9a9a\u64cd\u4f5c\u201d\uff1a",(0,s.jsx)(n.strong,{children:"\u53ef\u4ee5\u5728\u4efb\u4f55\u5730\u65b9\u521b\u5efa\u4f5c\u4e1a\u8c03\u5ea6\u670d\u52a1\uff0c\u591a\u6b21\u8c03\u7528\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u4f5c\u4e1a\u8c03\u5ea6\u5668\u3002"})]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:["\u63a8\u8350\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"Serve.Run()"})," \u6216 ",(0,s.jsx)(n.code,{children:"Serve.RunGeneric()"})," \u65b9\u5f0f\u66ff\u4ee3"]}),(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u63d0\u4f9b\u4e86 ",(0,s.jsx)(n.code,{children:"Serve.Run()"})," \u65b9\u5f0f\u652f\u6301\u8de8\u5e73\u53f0\u4f7f\u7528\uff0c\u8fd8\u80fd\u652f\u6301\u6ce8\u518c\u66f4\u591a\u670d\u52a1\uff0c\u5982\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3,5}",children:"Serve.Run(services =>\r\n{\r\n services.AddSchedule(options =>\r\n {\r\n options.Add(Triggers.Secondly());\r\n });\r\n})\n"})}),(0,s.jsxs)(n.p,{children:["\u5982\u65e0\u9700 ",(0,s.jsx)(n.code,{children:"Web"})," \u529f\u80fd\uff0c\u53ef\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"Serve.RunGeneric"})," \u66ff\u4ee3 ",(0,s.jsx)(n.code,{children:"Serve.Run"}),"\u3002"]})]}),"\n",(0,s.jsx)(n.h2,{id:"172-\u83b7\u53d6\u4f5c\u4e1a\u8c03\u5ea6\u8ba1\u5212\u5de5\u5382",children:"17.2 \u83b7\u53d6\u4f5c\u4e1a\u8c03\u5ea6\u8ba1\u5212\u5de5\u5382"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"var schedulerFactory = Schedular.GetFactory();\n"})}),"\n",(0,s.jsx)(n.h2,{id:"173-\u83b7\u53d6\u4f5c\u4e1a",children:"17.3 \u83b7\u53d6\u4f5c\u4e1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'var scheduler = Schedular.GetJob("\u4f5c\u4e1a Id");\n'})}),"\n",(0,s.jsx)(n.h2,{id:"174-\u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e",children:"17.4 \u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,5}",children:'// \u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\r\nvar args = new object[] { "* * * * * *", CronStringFormat.WithSeconds };\r\nvar stringArgs = Schedular.Serialize(args);\r\n\r\n// \u4f5c\u4e1a\u989d\u5916\u6570\u636e\r\nvar jobData = new Dictionary { { "name", "Furion" } };\r\nvar stringJobData = Schedular.Serialize(jobData);\n'})}),"\n",(0,s.jsx)(n.h2,{id:"175-\u53cd\u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e",children:"17.5 \u53cd\u5e8f\u5217\u5316\u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\u6216\u4f5c\u4e1a\u4fe1\u606f\u989d\u5916\u6570\u636e"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,5}",children:'// \u4f5c\u4e1a\u89e6\u53d1\u5668\u53c2\u6570\r\nvar stringArgs = "[\\"* * * * *\\",0]";\r\nvar args = Schedular.Deserialize(stringArgs);\r\n\r\n// \u4f5c\u4e1a\u989d\u5916\u6570\u636e\r\nvar stringJobData = "{\\"name\\":\\"Furion\\"}";\r\nvar args = Schedular.Deserialize>(stringJobData);\n'})})]})}function u(e={}){const{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},1151:(e,n,r)=>{r.d(n,{Z:()=>o,a:()=>d});var s=r(7294);const i={},t=s.createContext(i);function d(e){const n=s.useContext(t);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:d(e.components),s.createElement(t.Provider,{value:n},e.children)}}}]);