首页 > 编程语言 >C# 定时任务

C# 定时任务

时间:2024-12-31 14:08:34浏览次数:1  
标签:gt name C# lt param JobName 任务 定时 summary

C# 定时任务| Id | Title | DateAdded | SourceUrl | PostType | Body | BlogId | Description | DateUpdated | IsMarkdown | EntryName | CreatedTime | IsActive | AutoDesc | AccessPermission |

| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------| -------------|
| 17165281| C# 定时任务| 2023-02-28T17:26:00| | BlogPost|

C# 定时任务 - XL、 - 博客园 (cnblogs.com)

工作中需要做个每天定时发邮件的功能,了解之后知道java里有做定时任务比较容易的方法,就是Quartz,在C#里叫Quartz.Net。

在写代码之前需要引用几个dll文件,分别是C5.dll、Common.Logging.dll和Quartz.dll;还有一个QuartzManager.cs文件,直接复制到项目中

QuartzManager.cs

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Quartz;
using Quartz.Impl;
using Quartz.Impl.Triggers;

namespace Quartz
{
public static class QuartzManager
{
private static ISchedulerFactory sf = null;
private static IScheduler sched = null;

    </span><span style="color: #0000ff;">static</span><span style="color: #000000;"> QuartzManager()
    {
        sf </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> StdSchedulerFactory();
        sched </span>=<span style="color: #000000;"> sf.GetScheduler();
        sched.Start();
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以定点的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="CronTime"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="jobDataMap"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, <span style="color: #0000ff;">string</span> CronTime, <span style="color: #0000ff;">string</span> jobData) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        IJobDetail jobCheck </span>= JobBuilder.Create&lt;T&gt;().WithIdentity(JobName, JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_Group</span><span style="color: #800000;">"</span>).UsingJobData(<span style="color: #800000;">"</span><span style="color: #800000;">jobData</span><span style="color: #800000;">"</span><span style="color: #000000;">, jobData).Build();
        ICronTrigger CronTrigger </span>= <span style="color: #0000ff;">new</span> CronTriggerImpl(JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_CronTrigger</span><span style="color: #800000;">"</span>, JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_TriggerGroup</span><span style="color: #800000;">"</span><span style="color: #000000;">, CronTime);
        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> sched.ScheduleJob(jobCheck, CronTrigger);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以定点的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="CronTime"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, <span style="color: #0000ff;">string</span> CronTime) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        </span><span style="color: #0000ff;">return</span> AddJob&lt;T&gt;(JobName, CronTime, <span style="color: #0000ff;">null</span><span style="color: #000000;">);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以周期的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="SimpleTime"&gt;</span><span style="color: #008000;">毫秒数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, <span style="color: #0000ff;">int</span> SimpleTime) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        </span><span style="color: #0000ff;">return</span> AddJob&lt;T&gt;(JobName, DateTime.UtcNow.AddMilliseconds(<span style="color: #800080;">1</span><span style="color: #000000;">), TimeSpan.FromMilliseconds(SimpleTime));
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以周期的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="SimpleTime"&gt;</span><span style="color: #008000;">毫秒数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, DateTimeOffset StartTime, <span style="color: #0000ff;">int</span> SimpleTime) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        </span><span style="color: #0000ff;">return</span> AddJob&lt;T&gt;<span style="color: #000000;">(JobName, StartTime, TimeSpan.FromMilliseconds(SimpleTime));
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以周期的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="SimpleTime"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, DateTimeOffset StartTime, TimeSpan SimpleTime) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        </span><span style="color: #0000ff;">return</span> AddJob&lt;T&gt;(JobName, StartTime, SimpleTime, <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">object</span>&gt;<span style="color: #000000;">());
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以周期的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="StartTime"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="SimpleTime"&gt;</span><span style="color: #008000;">毫秒数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="jobDataMap"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, DateTimeOffset StartTime, <span style="color: #0000ff;">int</span> SimpleTime, <span style="color: #0000ff;">string</span> MapKey, <span style="color: #0000ff;">object</span> MapValue) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        Dictionary</span>&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">object</span>&gt; map = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">object</span>&gt;<span style="color: #000000;">();
        map.Add(MapKey, MapValue);
        </span><span style="color: #0000ff;">return</span> AddJob&lt;T&gt;<span style="color: #000000;">(JobName, StartTime, TimeSpan.FromMilliseconds(SimpleTime), map);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 添加Job 并且以周期的形式运行
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="StartTime"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="SimpleTime"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="jobDataMap"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> DateTimeOffset AddJob&lt;T&gt;(<span style="color: #0000ff;">string</span> JobName, DateTimeOffset StartTime, TimeSpan SimpleTime, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">object</span>&gt; map) <span style="color: #0000ff;">where</span><span style="color: #000000;"> T : IJob
    {
        IJobDetail jobCheck </span>= JobBuilder.Create&lt;T&gt;().WithIdentity(JobName, JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_Group</span><span style="color: #800000;">"</span><span style="color: #000000;">).Build();
        jobCheck.JobDataMap.PutAll(map);
        ISimpleTrigger triggerCheck </span>= <span style="color: #0000ff;">new</span> SimpleTriggerImpl(JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_SimpleTrigger</span><span style="color: #800000;">"</span>, JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_TriggerGroup</span><span style="color: #800000;">"</span><span style="color: #000000;">,
                                    StartTime,
                                    </span><span style="color: #0000ff;">null</span><span style="color: #000000;">,
                                    SimpleTriggerImpl.RepeatIndefinitely,
                                    SimpleTime);
        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> sched.ScheduleJob(jobCheck, triggerCheck);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 修改触发器时间,需要job名,以及修改结果
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> CronTriggerImpl类型触发器
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> UpdateTime(<span style="color: #0000ff;">string</span> jobName, <span style="color: #0000ff;">string</span><span style="color: #000000;"> CronTime)
    {
        TriggerKey TKey </span>= <span style="color: #0000ff;">new</span> TriggerKey(jobName + <span style="color: #800000;">"</span><span style="color: #800000;">_CronTrigger</span><span style="color: #800000;">"</span>, jobName + <span style="color: #800000;">"</span><span style="color: #800000;">_TriggerGroup</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        CronTriggerImpl cti </span>= sched.GetTrigger(TKey) <span style="color: #0000ff;">as</span><span style="color: #000000;"> CronTriggerImpl;
        cti.CronExpression </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> CronExpression(CronTime);
        sched.RescheduleJob(TKey, cti);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 修改触发器时间,需要job名,以及修改结果
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> SimpleTriggerImpl类型触发器
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="jobName"&gt;&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="SimpleTime"&gt;</span><span style="color: #008000;">分钟数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> UpdateTime(<span style="color: #0000ff;">string</span> jobName, <span style="color: #0000ff;">int</span><span style="color: #000000;"> SimpleTime)
    {
        UpdateTime(jobName, TimeSpan.FromMinutes(SimpleTime));
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 修改触发器时间,需要job名,以及修改结果
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> SimpleTriggerImpl类型触发器
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> UpdateTime(<span style="color: #0000ff;">string</span><span style="color: #000000;"> jobName, TimeSpan SimpleTime)
    {
        TriggerKey TKey </span>= <span style="color: #0000ff;">new</span> TriggerKey(jobName + <span style="color: #800000;">"</span><span style="color: #800000;">_SimpleTrigger</span><span style="color: #800000;">"</span>, jobName + <span style="color: #800000;">"</span><span style="color: #800000;">_TriggerGroup</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        SimpleTriggerImpl sti </span>= sched.GetTrigger(TKey) <span style="color: #0000ff;">as</span><span style="color: #000000;"> SimpleTriggerImpl;
        sti.RepeatInterval </span>=<span style="color: #000000;"> SimpleTime;
        sched.RescheduleJob(TKey, sti);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 暂停所有Job
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 暂停功能Quartz提供有很多,以后可扩充
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> PauseAll()
    {
        sched.PauseAll();
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 恢复所有Job
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 恢复功能Quartz提供有很多,以后可扩充
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> ResumeAll()
    {
        sched.ResumeAll();
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 删除Job
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 删除功能Quartz提供有很多,以后可扩充
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="JobName"&gt;&lt;/param&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> DeleteJob(<span style="color: #0000ff;">string</span><span style="color: #000000;"> JobName)
    {
        JobKey jk </span>= <span style="color: #0000ff;">new</span> JobKey(JobName, JobName + <span style="color: #800000;">"</span><span style="color: #800000;">_Group</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        sched.DeleteJob(jk);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 卸载定时器
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="waitForJobsToComplete"&gt;</span><span style="color: #008000;">是否等待job执行完成</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Shutdown(<span style="color: #0000ff;">bool</span><span style="color: #000000;"> waitForJobsToComplete)
    {
        sched.Shutdown(waitForJobsToComplete);
    }
}

}

窗体界面上只有一个Button按钮,点击之后将当前Windows窗体关闭,而我的定时任务就是实现这个关闭。

.closeForm();关闭窗体方法在另写的一个stopjob.cs类文件调用 这个类需要继承IJob

复制代码
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace winform状态栏
{
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
public class stopjob : IJob
{
public void Execute(IJobExecutionContext context)
{
Program.form.closeForm();
}
}
}

复制代码

上面代码中,Program.form并不是开始创建的那个窗体,而是在Program类文件中创建的静态Form。为什么另创建一个静态Form?涉及到子线程关闭主线程问题

复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace winform状态栏
{
static class Program
{

    public static Form1 form;
    /// &lt;summary&gt;
    /// 应用程序的主入口点。
    /// &lt;/summary&gt;
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        form = new Form1();
        Application.Run(form);
    }
}

}

复制代码

Form.cs文件里引用Quartz(using Quartz;)

然后是关闭按钮(Button)的事件

复制代码
using Quartz;
using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace winform状态栏
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void button_close(object sender, EventArgs e)
    {
        //cron表达式 参考 http://www.cnblogs.com/sunjie9606/archive/2012/03/15/2397626.html
        QuartzManager.AddJob&lt;stopjob&gt;("每隔5秒", "*/5 * * * * ?");//每隔5秒执行一次这个方法
    }

    private delegate void CloseForm();//设计到多线程,子线程去控制主线程的控件,InvokeRequired值为true,用到定义委托,使得这个控制行为成为主线程的行为

    public void closeForm()
    {
        if (this.InvokeRequired)
        {
            this.BeginInvoke(new CloseForm(closeForm));
        }
        else
        {
            this.Close();
        }
    }
}

}

复制代码

关于执行stopjob的时间,我这里是用的每隔5秒执行一次,具体的解释在另一位博主那里有介绍 

http://www.cnblogs.com/sunjie9606/archive/2012/03/15/2397626.html

其中C5.dll、Common.Logging.dll、Quartz.dll文件的链接http://pan.baidu.com/s/1hsBn1Bm(如果失效联系博主)

我学习Quartz.Net时用的是winform,大家可以试试别的,这样关于线程的问题应该就可以避免,这也是我没有想到的问题

| 648658| | 2024-04-29T20:51:00| false| | 2023-02-28T17:25:55.4| true| C# 定时任务 - XL、 - 博客园 (cnblogs.com) 工作中需要做个每天定时发邮件的功能,了解之后知道java里有做定时任务比较容易的方法,就是Quartz,在C#里叫Quartz.Net。 在写代码之前需要引用几个dll文件,分别是C5.dll、Common.Logging.dll和| Anonymous|

标签:gt,name,C#,lt,param,JobName,任务,定时,summary
From: https://www.cnblogs.com/ralphlauren/p/18621185

相关文章

  • Dictionary 添加重复的键值对
    Dictionary添加重复的键值对|Id|Title|DateAdded|SourceUrl|PostType|Body|BlogId|Description|DateUpdated|IsMarkdown|EntryName|CreatedTime|IsActive|AutoDesc|AccessPermission||-------------|-------------|-------------|-----------......
  • C生成曲线BMP
    C生成曲线BMP|Id|Title|DateAdded|SourceUrl|PostType|Body|BlogId|Description|DateUpdated|IsMarkdown|EntryName|CreatedTime|IsActive|AutoDesc|AccessPermission||-------------|-------------|-------------|-------------|-----------......
  • centos7 下 nginx 启动,关闭,重启配置 -
    centos7下nginx启动,关闭,重启配置-|Id|Title|DateAdded|SourceUrl|PostType|Body|BlogId|Description|DateUpdated|IsMarkdown|EntryName|CreatedTime|IsActive|AutoDesc|AccessPermission||-------------|-------------|-------------|---......
  • JavaSpring AI与阿里云通义大模型的集成使用Java Data Science Library(JDSL)进行数据处
    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站学习总结1、掌握JAVA入门到进阶知识(持续写作中……)2、学会Oracle数据库入门到入土用法(创作中……)3、手把手教你开发炫酷的vbs脚本制作(完善中……)4、牛逼哄哄的IDEA......
  • CTF入门教程(非常详细)从零基础入门到竞赛,看这一篇就够了!
    目录一、CTF简介二、CTF竞赛模式三、CTF各大题型简介四、CTF学习路线4.1、初期1、html+css+js(2-3天)2、apache+php(4-5天)3、mysql(2-3天)4、python(2-3天)5、burpsuite(1-2天)4.2、中期1、SQL注入(7-8天)2、文件上传(7-8天)3、其他漏洞(14-15天)4.3、后期五、CTF学......
  • 2024.12.30 由于不会制表痛失一份工作,学习excel制表
    单元格格式可以用来切换其中内容的格式,小技巧,数值右对齐,文字左对齐单元格内换行输出使用Alt+Enter在>数据->分列中可以将某个单元格中的数据分成不同的列1.随机函数rand()返回一个0-1之间的数字,且图表每次更新都会进行随机randbetween(low,high)返回一个low与high之间的任一整......
  • Docker入门之docker-compose
    一,Docker-compose简介1,Docker-compose简介Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。Docker-Compose将所管理的容器分为三层,分别是工程(project),服务(service)以及容器(container)。Docker-Compose运行目录下的所有文件(docker-compose.yml,extend......
  • Python定时任务
    @目录几种方法schedulerepeat多个取消一次标记与识别截止调试运行APScheduler几种方法scheduleimportscheduleimporttimedefdoLoops(): print(1)schedule.every(1).seconds.do(doLoops)schedule.every(1).minutes.do(doLoops)schedule.every().hour.do(doLoops)......
  • Android RadioButton与container左侧padding调整
    遇到了这个问题:Android:Setmargintoleftsideofradiobuttondrawable同时在这个情景下并不能修改controller内容,希望通过xml达到这个效果。一般是通过添加android:paddingLeft来达到效果,但在RadioButton中它修改的是radio和text之间的距离。另一种方法是在外面套一个Linea......
  • C语言数组名的理解
    一维数组intmain(){ inta[]={1,2,3,4}; printf("%zu\n",sizeof(a)); printf("%zu\n",sizeof(a+0)); printf("%zu\n",sizeof(*a)); printf("%zu\n",sizeof(a+1)); printf("%zu\n",sizeof(a[1])); prin......