jazzIIIlove
asked on
progress bar on function execution C# WinForms
Hi;
I need a progress bar that is mapped to an extraction of a zip file on windows forms but for some reason, i am failing in this code.
Any help?
I need a progress bar that is mapped to an extraction of a zip file on windows forms but for some reason, i am failing in this code.
Any help?
private void extractZipButton_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem((obj) =>
{
ExtractZipFile(new FileInfo(Path.GetFullPath(_tomcatPath)));
Parallel.For(0, 100, i =>
{
Invoke(new Action(() =>
{
extractProgressBar.Value = (i * 100) / 10;
}));
});
});
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi;
Unfortunately it is not working and it crashes now. Any ideas?
Best regards
Unfortunately it is not working and it crashes now. Any ideas?
Best regards
ASKER
When I debug, the error is
Cross-thread operation not valid: Control 'diagnosticsTextBox' accessed from a thread other than the thread it was created on.
Cross-thread operation not valid: Control 'diagnosticsTextBox' accessed from a thread other than the thread it was created on.
ASKER
I will check this tomorrow.
Best regards.