private void extractAllToDirectory(object sender, object arg) { BackgroundWorker backgroundWorker = (BackgroundWorker)sender; String directory = String.Empty; try { directory = (String)arg; } catch (InvalidCastException) { return; } for (Int32 i = 0; i < Packs.Count; ++i) { Pack pack = Packs.ElementAt(i); pack.ExtractAllAssetsToDirectory(directory); Single percent = (Single)(i + 1) / (Single)Packs.Count; backgroundWorker.ReportProgress((Int32)(percent * 100.0f), System.IO.Path.GetFileName(pack.Path)); } }