как сделать progressbar для просмотра процесса вычисления

Хочу видеть процесс вычисления числа пи, но не знаю как применить progressbar, а точнее когда прописываю его в методе, он начинает ругаться /// public partial class Form1 : Form {

    static List<double> n_circle_List = new List<double>();
    static List<double> n_square_List = new List<double>();
    static void Method_Monte_Karlo(object num_p)
    {
        int n_point = (int)num_p;
        double n_circle = 0;
        double n_square = 0;
        int n_point_count = n_point;
        int count= n_point;
        Random r = new Random();
         for (int i = 0; i < n_point; i++)
        {
            if (IsPointInCircle(1.0, r.NextDouble(), r.NextDouble()))
            {
                n_circle++;
            }
            if(IsPointInSquare(r.NextDouble(), r.NextDouble()))
            {
                n_square++;
            }
        }
        n_circle_List.Add(n_circle); // piList.Add((4 * n_circle) / (double)n_point);
        n_square_List.Add(n_square);
    }
    static bool IsPointInCircle(double R, double x, double y)
    {
        return ((x * x + y * y) <= R * R);
    }

    static bool IsPointInSquare(double x, double y)
    {
        if(!IsPointInCircle(1.0, x, y) && x<=1 && y<=1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    static void Threads(int numThreads, int num)
    {
        ThreadPool.SetMaxThreads(numThreads, 0);
        for (int i = 0; i < numThreads; i++)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(Method_Monte_Karlo), num);
            Thread.Sleep(20);

        }

    }
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        int numThr;
        int _num;
        numThr = int.Parse(textBox1.Text);
        _num = int.Parse(textBox2.Text); 
        Threads(numThr, _num);
        textBox6.Clear();
        progressBar1.Value = 1;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        double j = 0;
        double k = 0;
        double pi = 0;
        double _num;
        _num = int.Parse(textBox2.Text);
        for (int i = 0; i < n_circle_List.Count; i++)
        {
            j += n_circle_List[i];
            k += n_square_List[i];
        }
        j = j / n_circle_List.Count;
        k = k / n_square_List.Count;
        pi = 4 * j / _num;
        textBox6.Text = pi.ToString();
        n_circle_List.Clear();
        n_square_List.Clear();
    }
}

Ответы (0 шт):