diff --git a/Bonsai.Core/Reactive/Timer.cs b/Bonsai.Core/Reactive/Timer.cs index 63008fd88..6b649b94f 100644 --- a/Bonsai.Core/Reactive/Timer.cs +++ b/Bonsai.Core/Reactive/Timer.cs @@ -26,12 +26,12 @@ public class Timer : Source public TimeSpan DueTime { get; set; } /// - /// Gets or sets the period to produce subsequent values. If this value is equal - /// to the timer will recur as fast as possible. + /// Gets or sets the period to produce subsequent values. If this value is undefined + /// or equal to the timer will only fire once. /// [XmlIgnore] - [Description("The period to produce subsequent values. If this value is equal to zero the timer will recur as fast as possible.")] - public TimeSpan Period { get; set; } + [Description("The period to produce subsequent values. If this value is undefined or equal to zero the timer will only fire once.")] + public TimeSpan? Period { get; set; } /// /// Gets or sets an XML representation of the due time for serialization. @@ -53,8 +53,8 @@ public string DueTimeXml [EditorBrowsable(EditorBrowsableState.Never)] public string PeriodXml { - get { return XmlConvert.ToString(Period); } - set { Period = XmlConvert.ToTimeSpan(value); } + get { return Period > TimeSpan.Zero ? XmlConvert.ToString(Period.GetValueOrDefault()) : null; } + set { Period = string.IsNullOrEmpty(value) ? null : XmlConvert.ToTimeSpan(value); } } /// @@ -69,7 +69,7 @@ public override IObservable Generate() { var period = Period; return period > TimeSpan.Zero - ? Observable.Timer(DueTime, period) + ? Observable.Timer(DueTime, period.GetValueOrDefault()) : Observable.Timer(DueTime); } } diff --git a/Bonsai.Shaders/Timer.cs b/Bonsai.Shaders/Timer.cs index 72b203a3c..bf9fbfa8e 100644 --- a/Bonsai.Shaders/Timer.cs +++ b/Bonsai.Shaders/Timer.cs @@ -32,7 +32,7 @@ public class Timer : Source /// is undefined or equal to zero the timer will only fire once. /// [XmlIgnore] - [Description("The period to produce subsequent values. If this value is equal to zero the timer will recur as fast as possible.")] + [Description("The period to produce subsequent values. If this value is undefined or equal to zero the timer will only fire once.")] public TimeSpan? Period { get; set; } ///