I'm trying to read my zip faster to make my foreach loop parallel.
But how can i do that based on this method?
private async Task GetImage()
{
try
{
PathToZip();
int currentIndex = GetCurrentIndex();
Content content = _protocol.contents[currentIndex];
string imageName = $"{content.contentid}.jpg";
using (ZipArchive archive = ZipFile.OpenRead(PathToZip()))
{
foreach (ZipArchiveEntry pictureEntry in archive.Entries)
{
if (string.Equals(pictureEntry.Name, imageName, StringComparison.OrdinalIgnoreCase))
{
//for reading the image
byte[] buffer;
long length = pictureEntry.Length;
buffer = new byte[length];
pictureEntry.Open().Read(buffer, 0, (int)length);
myImage.Source = ImageSource.FromStream(() => new MemoryStream(buffer));
}
}
}
}
catch (Exception)
{
}
}
How can i do this?
Thanks in advance!