I have a winform that reads in a csv file on a second thread an writes the file data to a console. The main form has a progress bar. I wish to update the progress bar on the main form based on the lines of data read in the second thread. In my second thread function I use:
pBar.BeginInvoke((MethodInvoker)delegate
{
this.pBar.Value = (int) (((double) nRows) / ((double) fileLines));
});
不用说这似乎并不可行。 任何建议都将受到高度赞赏。
As an aside, should I use pBar.Show() and pBar.Hide() or set pBar.Visible in the second thread to show/hide the progress bar?
Thank you.