I am trying to update the components on my form with blocking its thread.
My program uses DotNetZip to add files into an archive and I am trying to update the progress bars to illustrate the progress made.
The SaveProgress method is called when the Save() starts. Before and after each entry has been written and when the Save() is finished.
At the moment the labels are not being updated and the progressBar1 does not update?
private void buttonCompress_Click(object sender, EventArgs e)
{
if ((folderBrowserDialog1.ShowDialog() == DialogResult.OK) && (saveFileDialog1.ShowDialog() == DialogResult.OK))
{
buttonCompress.Enabled = false;
String DirectoryToZip = folderBrowserDialog1.SelectedPath;
String ZipFileToCreate = saveFileDialog1.FileName;
using (ZipFile zip = new ZipFile())
{
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Default;
zip.SaveProgress += SaveProgress;
zip.StatusMessageTextWriter = System.Console.Out;
zip.AddDirectory(DirectoryToZip); // recurses subdirectories
zip.Save(ZipFileToCreate);
}
}
}