Quantcast
Channel: sharpcompress Discussions Rss Feed
Viewing all articles
Browse latest Browse all 239

New Post: Can you read entries concurrently?

$
0
0
Sorry, the code got cut
private async Task<string> SaveFileAsyncReadingSync(Stream streamSource, StorageFolder destinationStorageFolder, string destinationFileName)
        {
            var file = await destinationStorageFolder.CreateFileAsync(destinationFileName, CreationCollisionOption.ReplaceExisting);

            using (var ostream = await file.OpenStreamForWriteAsync())
            {
                int count = 0;
                do
                {
                    var buffer = new byte[1024];
                    count = streamSource.Read(buffer, 0, 1024);
                    await ostream.WriteAsync(buffer, 0, count);
                }
                while (count > 0);
            }
            return destinationStorageFolder.Name + "/" + file.Name;
        }
}
and it's called by:

SaveFileAsyncReadingSync(entry.OpenEntryStream(), folders[id], entry.FilePath)

where entry is each one of the RarArchiveEntry in my RARfile. The calls are concurrent, and the resulting images are corrupted. However if I do the calls sequentially everything works fine.

Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>