c#-4.0 - 如何在 Windows 2003 任务计划程序中为任务创建无限持续时间

标签 c#-4.0 scheduled-tasks windows-2003-webserver

我正在尝试创建无限期的任务。在 Windows Server 2008 上,如果我不指定持续时间,则持续时间被假定为无限。但是,在 Windows Server 2003 上,必须指定持续时间(并且等于或大于间隔)。目前,如果要重复很长时间,我只是将任务的持续时间设置为一年。

有没有办法在 Windows Server 2003 上指定无限期的持续时间?

if (m_TimeInterval.m_Expire.Year < 2099) //xp and win7 max year is 2099
    tTrigger.Repetition.Duration = m_TimeInterval.getDuration();
else if (!newVer) tTrigger.Repetition.Duration = m_TimeInterval.getInterval().Add(TimeSpan.FromDays(365));
tTrigger.Repetition.Interval = m_TimeInterval.getInterval();
tTrigger.Repetition.StopAtDurationEnd = true;

注释:

  • 我正在使用任务计划程序 API 添加这些任务定义。
  • 间隔和持续时间是通过使用 TimeSpans 设置的。
  • newVer 为 false,因为我使用的是任务计划程序 1.1,而不是 1.2 或更高版本
  • tTrigger 的类型为 TimeTrigger

最佳答案

我最终使用 1-1-2099 作为“不定”

关于c#-4.0 - 如何在 Windows 2003 任务计划程序中为任务创建无限持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10742880/

相关文章:

windows - 运行 matlab m 文件并从 Windows 7 调度程序提供参数

c# - C#中的 session 超时问题

c# - C# 中的 Int.Parse 抛出格式异常

c# - Autofac 无法解析外部 Controller 上的属性

c# - 使用另一个列表的内容过滤一个列表

c# - 在 C# 中旋转多列

java - 使用定时器在java中安排任务

email - 作为收件人,是否可以检测电子邮件是通过 Gmail 的 "Schedule Send"还是 "Send"发送的?