I'm trying to schedule "happen once" events, is Schedule.On appropriate for that? The reason I'm wondering is because it seems my backtest gets increasingly slower the longer it runs, I'm afraid events aren't removed and keep being tested (I've not been able to find in Lean code how they would be removed).

Background: I'm doing something like this to simulate order delay (side note: it would be nice with a different overload that simply took a TimeSpan assumed relative to current QCAlgorithm.Time):

private void BeginSubmitMarketOrder() { var delay = _delayGeneratorInSeconds(); if (Algorithm.LiveMode || delay <= 0) { SubmitMarketOrder(_orderParams); } else { //TODO: would prefer something that doesn't go bananas when at midnight... var now = Algorithm.Time; _inSimulatedSubmissionDelay = true; Algorithm.Schedule.On( Algorithm.Schedule.DateRules.On(now.Year, now.Month, now.Day), Algorithm.Schedule.TimeRules.At(now.TimeOfDay + TimeSpan.FromSeconds(delay)), () => SubmitMarketOrder(_orderParams.Clone()) ); } }