From e9a13dba49b94ba8cce2a4d3a13d08554fb334e9 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sat, 26 Aug 2023 00:12:31 -0400 Subject: [PATCH] print out thumbnail loading status to console --- Program.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index fda649c..c3050b9 100644 --- a/Program.cs +++ b/Program.cs @@ -378,6 +378,8 @@ public class Game : GameWindow { int VertexBufferObject; int ElementBufferObject; int VertexArrayObject; + readonly object thumbnailsLoadedLock = new(); + int thumbnailsLoaded = 0; List allPhotos = new(); List photos = new(); HashSet loadedImages = new(); @@ -720,9 +722,18 @@ public class Game : GameWindow { } private async void LoadThumbnailsAsync() { + List tasks = new(); foreach (Photo p in allPhotos) { - await Task.Run( () => { p.LoadThumbnailAsync(geometry.ThumbnailSize); }); + tasks.Add(Task.Run( () => { + p.LoadThumbnailAsync(geometry.ThumbnailSize); + lock (thumbnailsLoadedLock) { + thumbnailsLoaded++; + Console.WriteLine(thumbnailsLoaded); + } + })); } + Console.WriteLine("TASKS: " + tasks.Count); + await Task.WhenAll(tasks).ContinueWith(t => { Console.WriteLine("done????"); }); } // To find the JPEG compression level of a file from the command line: