I have around 500 JPEG images on a removable media device. My desktop app (.NET 4.5) is one Winforms form that currently contains FileInfo objects for these images in a List by using Directory.EnumerateFiles. No problem there and very quick. The main intent is to take all these files and upload them to an S3 bucket while also doing a bit of logging via a REST API call and reporting progress back to the user for all the files, and of course when the whole file set is done uploading.
How can I take this List of FileInfo objects and process them the most efficiently while also updating a progress bar and allowing the user to move the form without it freezing? Doing things in a simple ForEach loop obviously is slow. Processing each file involves uploading the image to an S3 bucket if certain metadata fields exist, writing to a REST API to store a record in a SQL database, then updating the UI to notify the user of progress as well as flagging the file in a visual data grid as "done". I can do all that code fine, but unsure of how to go through this list of files simultaneously while not causing UI issues on the form.
My real question: I heard many mention Parallel.ForEach, TPL, using Tasks, Async/Await, and I'm struggling to understand which is the best option for my use case, and how to go about it for updating the UI/progressbar without problems.