private async Task Init(CMMNExecutionContext executionContext, CaseEltInstance elt, CancellationToken token) { var currentDateTime = DateTime.UtcNow; var elapsedTime = ISO8601Parser.ParseTime(elt.GetTimerExpression().Body); var repeatingInterval = ISO8601Parser.ParseRepeatingTimeInterval(elt.GetTimerExpression().Body); if (repeatingInterval != null) { if (currentDateTime >= repeatingInterval.Interval.EndDateTime) { return; } var startDate = currentDateTime; if (startDate < repeatingInterval.Interval.StartDateTime) { startDate = repeatingInterval.Interval.StartDateTime; } var diff = repeatingInterval.Interval.EndDateTime.Subtract(startDate); var newTimespan = new TimeSpan(diff.Ticks / (repeatingInterval.RecurringTimeInterval)); for (var i = 0; i < repeatingInterval.RecurringTimeInterval; i++) { currentDateTime = currentDateTime.Add(newTimespan); var newInstance = elt; if (i > 0) { newInstance = executionContext.Instance.TryCreateInstance(elt); } await TrySubscribe(executionContext, newInstance, CMMNConstants.ExternalTransitionNames.Occur, token); await _messageScheduler.SchedulePublish(currentDateTime, BuildEvent(executionContext.Instance.AggregateId, newInstance.Id), token); } } if (elapsedTime != null) { if (currentDateTime >= elapsedTime) { return; } await TrySubscribe(executionContext, elt, CMMNConstants.ExternalTransitionNames.Occur, token); await _messageScheduler.SchedulePublish(elapsedTime.Value, BuildEvent(executionContext.Instance.AggregateId, elt.Id), token); } }