public static void CalculateAttributions(BackgroundWorker worker, string _filename, ComboBox cmb, OpenFileDialog open)
{
worker = new BackgroundWorker { WorkerReportsProgress = true };
while (wave.Position != length)
{
...Process..
worker.ReportProgress((100 * (int)(length / wave.Position)) / (int)(length / mainBuffer.Length));
}
}
我在一个类中编写了这个方法来执行我的计算并BackgroundWorker
用作参数来显示一个Progressbar
during 循环。但是,当我在Form.cs
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = Math.Min(e.ProgressPercentage, 100);
}
此事件不起作用,因此ProgressBar
值不会改变。我怎样才能让它工作?