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: