private void DoPostUpdateActions(ComponentWrapperBase componentWrapper, int delay) { componentWrapper.Ticker.Advance(); // When we've run the scene once through, we need to check if there are repeatable frames // If there aren't any, then we terminate running by not scheduling the next task. if (componentWrapper.Ticker.Index == 0 && !componentWrapper.Scene.HasRepeatableFrames) { return; } ScheduleTask(componentWrapper, delay); }
private void ScheduleTask(ComponentWrapperBase componentWrapper, int delay) { var cancellationToken = new CancellationTokenSource(); Task.Run(async delegate { await Task.Delay(TimeSpan.FromMilliseconds(delay), cancellationToken.Token); foreach (var component in componentWrapper.GetNextComponentsToRun()) { engineActor.UpdateComponent(component, RunMode.Asynchronous); } DoPostUpdateActions(componentWrapper, componentWrapper.GetNextFrameLength()); }, cancellationToken.Token); componentWrapper.Run(cancellationToken); }
public void MergeComposite(ComponentWrapperBase newComponentWrapper) { var newDirectionalComponentWrapper = (CompositeComponentWrapper) newComponentWrapper; var existingComponent = wrappedComponents .SingleOrDefault(cmp => ((CompositeComponentWrapper) cmp) .DirectionalComponent.Equals(newDirectionalComponentWrapper.DirectionalComponent)); if (existingComponent != null) { existingComponent.CancellationToken.Cancel(); wrappedComponents.Remove(existingComponent); } wrappedComponents.Add(newComponentWrapper); }