diff --git a/src/RecurrentTasks/RecurrentTasks.csproj b/src/RecurrentTasks/RecurrentTasks.csproj
index 47ce9e9..7fac9fb 100644
--- a/src/RecurrentTasks/RecurrentTasks.csproj
+++ b/src/RecurrentTasks/RecurrentTasks.csproj
@@ -11,7 +11,7 @@
git
https://github.com/justdmitry/RecurrentTasks.git
- 6.4.0
+ 6.4.1
RecurrentTasks for .NET allows you to run simple recurrent background tasks with specific intervals, without complex frameworks, persistance, etc...
just_dmitry
diff --git a/src/RecurrentTasks/TaskOptions.cs b/src/RecurrentTasks/TaskOptions.cs
index 268c274..2878d66 100644
--- a/src/RecurrentTasks/TaskOptions.cs
+++ b/src/RecurrentTasks/TaskOptions.cs
@@ -6,6 +6,14 @@
public class TaskOptions
{
+ ///
+ /// Maximum allowed and values.
+ ///
+ public static readonly TimeSpan MaxInterval = TimeSpan.FromMilliseconds(int.MaxValue);
+
+ private TimeSpan interval;
+ private TimeSpan firstRunDelay = TimeSpan.FromSeconds(new Random().Next(10, 30));
+
///
/// If non-null, current thread culture will be set to this value before is called
///
@@ -17,15 +25,48 @@ public class TaskOptions
public bool AutoStart { get; set; } = true;
///
- /// Task run interval
+ /// Task run interval.
///
- public TimeSpan Interval { get; set; }
+ public TimeSpan Interval
+ {
+ get
+ {
+ return interval;
+ }
+
+ set
+ {
+ if (value > MaxInterval)
+ {
+ throw new ArgumentOutOfRangeException(nameof(Interval), "Must be less than Int32.MaxValue milliseconds (approx. 24 days 20 hours)");
+ }
+
+ interval = value;
+ }
+ }
///
/// First run delay (to prevent app freeze during startup due to many tasks initialization).
/// Default is random value from 10 to 30 seconds.
///
- public TimeSpan FirstRunDelay { get; set; } = TimeSpan.FromSeconds(new Random().Next(10, 30));
+ public TimeSpan FirstRunDelay
+ {
+ get
+ {
+ return interval;
+ }
+
+ set
+ {
+ if (value > MaxInterval)
+ {
+ throw new ArgumentOutOfRangeException(nameof(FirstRunDelay), "Must be less than Int32.MaxValue milliseconds (approx. 24 days 20 hours)");
+ }
+
+ interval = value;
+ }
+ }
+
///
/// Return false to cancel/skip task run