C# 与进度条平行

C# 与进度条平行,c#,parallel-processing,progress-bar,C#,Parallel Processing,Progress Bar,我有以下代码: Parallel.For(0, img.Count(), i => { img[i].Scale = escala_axial; Bitmap tmp_b = new Bitmap((System.Drawing.Image)img[i].RenderImage(0)); tmp_b = filtro.Apply(tmp_b); imagenes[

我有以下代码:

        Parallel.For(0, img.Count(), i =>
        {
            img[i].Scale = escala_axial;
            Bitmap tmp_b = new Bitmap((System.Drawing.Image)img[i].RenderImage(0));
            tmp_b = filtro.Apply(tmp_b);
            imagenes[i] = tmp_b;
            Progress_Bar_Loading_Images.Invoke((MethodInvoker)(delegate() { Progress_Bar_Loading_Images.Value++; }));
        });
它在没有ProgressBar调用的情况下运行良好。现在,当我使用Invoke时,它看起来好像永远不会结束循环,屏幕冻结。你知道问题出在哪里吗

谢谢

编辑:

答案是:谢谢你的反馈

        Parallel.For(0, img.Count(), i =>
        {
            img[i].Scale = escala_axial;
            Bitmap tmp_b = new Bitmap((System.Drawing.Image)img[i].RenderImage(0));
            tmp_b = filtro.Apply(tmp_b);
            imagenes[i] = tmp_b;
            this.Invoke(new Action(() => Progress_Bar_Loading_Images.Value++));
        });

使用以下命令代替progressbar.Invoke():

//rest of loop....
this.Invoke(/*your code here*/);

谢谢,我使用了这个:
this.Invoke(新操作(()=>Progress\u-Bar\u-Loading\u-Images.Value++))