private void PlayIntroAnimation() { FrameRendering += DrawOverlay; _introAnimation = new IntroAnimation(_logger, _profileService, _surfaceService); // Draw a white overlay over the device void DrawOverlay(object sender, FrameRenderingEventArgs args) { if (_introAnimation == null) { args.Canvas.Clear(new SKColor(0, 0, 0)); } else { _introAnimation.Render(args.DeltaTime, args.Canvas, _rgbService.BitmapBrush.Bitmap.Info); } } TimeSpan introLength = _introAnimation.AnimationProfile.GetAllLayers().Max(l => l.TimelineLength); // Stop rendering after the profile finishes (take 1 second extra in case of slow updates) Task.Run(async() => { await Task.Delay(introLength.Add(TimeSpan.FromSeconds(1))); FrameRendering -= DrawOverlay; _introAnimation.AnimationProfile?.Dispose(); _introAnimation = null; }); }