private async void PlayGif_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ProcessingGif = true; var metadata = await HttpClientFactory.AppApiService().GetUgoiraMetadata(Illust.Id); var ugoiraZip = metadata.UgoiraMetadataInfo.ZipUrls.Medium; var delay = metadata.UgoiraMetadataInfo.Frames.Select(f => f.Delay / 10).ToArray(); var streams = InternalIO.ReadGifZipEntries(await PixivIO.GetBytes(ugoiraZip)).ToArray(); ProcessingGif = false; PlayingGif = true; #pragma warning disable 4014 Task.Run(async() => { while (!cancellationToken.IsCancellationRequested) { for (var i = 0; i < streams.Length && !cancellationToken.IsCancellationRequested; i++) { streams[i].Position = 0; ImgSource = InternalIO.CreateBitmapImageFromStream(streams[i]); await Task.Delay((int)delay[i], cancellationToken.Token); } } }); #pragma warning restore 4014 }