Problem using C# and .Net Framework 4.5 tasks with SevenZipSharp

Dec 17, 2012 at 4:38 PM
Edited Dec 17, 2012 at 4:39 PM

New to the forum. I'm writing a little utility that uses 7zip to validate a set of archive files. The program uses .NET 4.5 Tasks to check files in parallel.

As I increase the number of parallel activities I get a corresponding increase in the number of dictionary key exceptions thown by SevenZipSharp or false failures reported by Check(). Reducing the array size to a single task allows the program to complete without issue. A lot of this is new to me so I'm probably doing something wrong but too ignorant to know what it might be. Any thoughts or assistance would be appreciated.

...

[

STAThread]

static void Main(string [] args)

...

Task[] parallelTasks = new Task[4]; ... private void WalkFilesInDirectory(DirectoryInfo path) { string[] filter = { ".rar", ".zip", ".cbr", ".cbz" }; foreach (FileInfo f in path.GetFiles("*.*")) { int i = 0; do { if (i < 0) Thread.Sleep(50); i = Array.IndexOf(parallelTasks, null); if (i < 0) i = Array.FindIndex(parallelTasks, t => t.IsCompleted || t.IsFaulted); } while (i < 0); string extension = Path.GetExtension(f.Name).ToLower(); if (Array.Exists(filter, x => extension == x)) { parallelTasks[i] = Task.Factory.StartNew(() => { SevenZipExtractor archive = new SevenZipExtractor(f.FullName); if (archive.Check() == false) Console.WriteLine("Audit failed for " + f.FullName); }); } } } }

Jun 11, 2013 at 5:10 PM
dickb,

Did you discover the problem?

I'm exact same things experiencing the same things.