{"record":{"id":"7945f42074ff7451","repo":"AvaloniaUI/Avalonia","slug":"delaybetweeniterations-value-cannot-be-negative","errorCode":null,"errorMessage":"DelayBetweenIterations value cannot be negative.","messagePattern":"DelayBetweenIterations value cannot be negative\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/AnimationInstance`1.cs","lineNumber":101,"sourceCode":"        {\n            _easeFunc = _animation.Easing;\n\n            _speedRatioPrev = _speedRatio;\n            _speedRatio = _animation.SpeedRatio;\n            if (_speedRatio < 0d)\n                throw new InvalidOperationException(\"SpeedRatio value cannot be negative.\");\n\n            _initialDelay = _animation.Delay;\n            if (_initialDelay < TimeSpan.Zero)\n                throw new InvalidOperationException(\"Delay value cannot be negative.\");\n\n            _duration = _animation.Duration;\n            if (_duration < TimeSpan.Zero)\n                throw new InvalidOperationException(\"Duration value cannot be negative.\");\n\n            _iterationDelay = _animation.DelayBetweenIterations;\n            if (_iterationDelay < TimeSpan.Zero)\n                throw new InvalidOperationException(\"DelayBetweenIterations value cannot be negative.\");\n\n            if (_animation.IterationCount.RepeatType == IterationType.Many)\n            {\n                if (_animation.IterationCount.Value > long.MaxValue)\n                    throw new InvalidOperationException(\"IterationCount value cannot be larger than long.MaxValue.\");\n                _iterationCount = (long)_animation.IterationCount.Value;\n            }\n            else\n            {\n                _iterationCount = null;\n            }\n\n            _playbackDirectionPrev = _playbackDirection;\n            _playbackDirection = _animation.PlaybackDirection;\n            _fillMode = _animation.FillMode;\n        }\n\n        protected override void Unsubscribed()","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/AnimationInstance`1.cs#L83-L119","documentation":"Thrown by AnimationInstance<T>.FetchProperties when the Animation.DelayBetweenIterations property is negative. This is the idle gap inserted between repeated iterations; Avalonia rejects negative values because the iteration scheduler assumes non-negative delays.","triggerScenarios":"Running an Animation with DelayBetweenIterations set to a negative TimeSpan; reached in FetchProperties when _animation.DelayBetweenIterations < TimeSpan.Zero.","commonSituations":"Setting DelayBetweenIterations from a computed or bound value that can go negative; confusing it with SpeedRatio or a signed offset; deserializing a config with a bad sign.","solutions":["Clamp DelayBetweenIterations to zero or a positive span before running the animation.","Correct the binding/calculator that emits a negative iteration delay.","Leave DelayBetweenIterations at its default (TimeSpan.Zero) if you do not need inter-iteration gaps."],"exampleFix":"// before\nanimation.DelayBetweenIterations = computedGap;\n\n// after\nanimation.DelayBetweenIterations = computedGap < TimeSpan.Zero ? TimeSpan.Zero : computedGap;","handlingStrategy":"validation","validationCode":"if (animation.DelayBetweenIterations < TimeSpan.Zero)\n    animation.DelayBetweenIterations = TimeSpan.Zero;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default DelayBetweenIterations to TimeSpan.Zero unless inter-iteration gaps are intended.","Validate bound timing values at the model boundary.","Document which timing properties are non-negative."],"tags":["animation","validation","timespan","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}