I'm having some problems with the file extraction. Everything works well with the progress bar output and the extraction. But when it is running the UI freezes. I've tried to use Task.Run()
but then it doesn't really work well with the progress bar. Or maybe I just didn't use it correctly.
Any suggestions?
private void unzip(string path)
{
this.progressBar1.Minimum = 0;
this.progressBar1.Maximum = 100;
progressBar1.Value = 0;
this.progressBar1.Visible = true;
var sevenZipPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
SevenZipBase.SetLibraryPath(sevenZipPath);
var file = new SevenZipExtractor(path + @"\temp.zip");
file.Extracting += (sender, args) =>
{
this.progressBar1.Value = args.PercentDone;
};
file.ExtractionFinished += (sender, args) =>
{
// Do stuff when done
};
//Extract the stuff
file.ExtractArchive(path);
}