I have a parsing function, It parse a file and take a long time. I want to show a progress bar while the function parsing the file. I add toolstripprogressbar and set its properties. However I dont know how they are run synchronously.
I want to do something like this:
// progressBar start progress
parseFile();
// progressBar finish progress
I searched about it, for loop and thread are used for this, but they are not helpful for me. How can I do this?
You really need to run the long running operation in a background thread, which can periodically report back to the GUI thread about how it's doing (and, in the process, update your progress bar).
I'd urge you to read about Background Worker, here http://www.dotnetperls.com/backgroundworker
MSDN Page here : http://msdn.microsoft.com/en-us/library/8xs8549b.aspx
You can also see a very similar SO question here: C# Winform ProgressBar and BackgroundWorker