/// <inheritdoc /> public ITask ScheduleUpdate(ILifecycleObject @object, Action action, string taskName, ExecutionTargetContext target) { ThreadSafeTask task; lock (taskIdLock) { task = new ThreadSafeTask(taskId++, taskName, this, @object, action, target); } lock (lockObj) { tasks.Add(task); } return(task); }
/// <inheritdoc /> public ITask ScheduleAt(ILifecycleObject @object, Action action, string taskName, DateTime date, bool runAsync = false) { ThreadSafeTask task; ExecutionTargetContext context = runAsync ? ExecutionTargetContext.Async : ExecutionTargetContext.NextFrame; lock (taskIdLock) { task = new ThreadSafeTask(taskId++, taskName, this, @object, action, context, TimeSpan.Zero, date, null); } lock (lockObj) { tasks.Add(task); } return(task); }
/// <inheritdoc /> public ITask SchedulePeriodically(ILifecycleObject @object, Action action, string taskName, TimeSpan period, TimeSpan?delay = null, bool runAsync = false) { ThreadSafeTask task; ExecutionTargetContext context = runAsync ? ExecutionTargetContext.Async : ExecutionTargetContext.NextFrame; DateTime startTime = DateTime.UtcNow; if (delay != null) { startTime = startTime.Add(delay.Value); } lock (taskIdLock) { task = new ThreadSafeTask(taskId++, taskName, this, @object, action, context, period, startTime, null); } lock (lockObj) { tasks.Add(task); } return(task); }