Click or drag to resize
Task Scheduler Managed Class Library

RepetitionPattern Class

Defines how often the task is run and how long the repetition pattern is repeated after the task is started.
Inheritance Hierarchy
SystemObject
  Microsoft.Win32.TaskSchedulerRepetitionPattern

Namespace: Microsoft.Win32.TaskScheduler
Assembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.12.0
Syntax
C#
[XmlRootAttribute("Repetition", Namespace = "http://schemas.microsoft.com/windows/2004/02/mit/task", 
	IsNullable = true)]
public sealed class RepetitionPattern : IDisposable, 
	IXmlSerializable, IEquatable<RepetitionPattern>, INotifyPropertyChanged
Request Example View Source

The RepetitionPattern type exposes the following members.

Constructors
 NameDescription
Public methodRepetitionPatternInitializes a new instance of the RepetitionPattern class.
Top
Properties
 NameDescription
Public propertyDurationGets or sets how long the pattern is repeated.
Public propertyIntervalGets or sets the amount of time between each restart of the task.
Public propertyStopAtDurationEnd Gets or sets a Boolean value that indicates if a running instance of the task is stopped at the end of repetition pattern duration.
Top
Methods
 NameDescription
Public methodDisposeReleases all resources used by this class.
Public methodEquals(Object)Determines whether the specified Object, is equal to this instance.
(Overrides ObjectEquals(Object))
Public methodEquals(RepetitionPattern)Indicates whether the current object is equal to another object of the same type.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetHashCodeReturns a hash code for this instance.
(Overrides ObjectGetHashCode)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodIsSetDetermines whether any properties for this RepetitionPattern have been set.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Events
 NameDescription
Public eventPropertyChangedOccurs when a property value changes.
Top
Remarks
This can be used directly or by assignment for a Trigger.
Example
C#
// Create a time trigger with a repetition
var tt = new TimeTrigger(new DateTime().Now.AddHours(1));
// Set the time in between each repetition of the task after it starts to 30 minutes.
tt.Repetition.Interval = TimeSpan.FromMinutes(30); // Default is TimeSpan.Zero (or never)
// Set the time the task will repeat to 1 day.
tt.Repetition.Duration = TimeSpan.FromDays(1); // Default is TimeSpan.Zero (or never)
// Set the task to end even if running when the duration is over
tt.Repetition.StopAtDurationEnd = true; // Default is false;

// Do the same as above with a constructor
tt = new TimeTrigger(new DateTime().Now.AddHours(1)) { Repetition = new RepetitionPattern(TimeSpan.FromMinutes(30), TimeSpan.FromDays(1), true) };
See Also