I want to show progress of calculations, which are performing in external library.
For example if I have some calculate method, and I want to use it for 100000 values in my Form class I can write:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }            
    private void Caluculate(int i)
    {
        double pow = Math.Pow(i, i);
    }
    private void button1_Click(object sender, EventArgs e)
    {
        progressBar1.Maximum = 100000;
        progressBar1.Step = 1;
        for(int j = 0; j < 100000; j++)
        {
            Caluculate(j);
            progressBar1.PerformStep();
        }
    }
}
I should perform step after each calculation. But what if I perform all 100000 calculations in external method. When should I "perform step" if I don't want to make this method dependant on progress bar? I can, for example, write
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    private void CaluculateAll(System.Windows.Forms.ProgressBar progressBar)
    {
        progressBar.Maximum = 100000;
        progressBar.Step = 1;
        for(int j = 0; j < 100000; j++)
        {
            double pow = Math.Pow(j, j); //Calculation
            progressBar.PerformStep();
        }
    }
    private void button1_Click(object sender, EventArgs e)
    {
        CaluculateAll(progressBar1);
    }
}
but I don't want to do like that.
 
     
     
     
     
     
     
     
    