“此BackgroundWorker声明它不报告进度." - 为什么? [英] "This BackgroundWorker states that it doesn't report progress." - Why?

查看:785
本文介绍了“此BackgroundWorker声明它不报告进度." - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个背景工作人员的新手
我已经阅读了一些有关如何创建一个的文章
这就是它产生的

i am new to this backgroundworker thing
i have read some articles about how to create one
this is what it produced

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        Bitmap imgbox = new Bitmap(pictureBox.Image);

        int imgHeight = imgbox.Height;
        int imgWidth = imgbox.Width;

        int counter = 1;

        MinMaxWidth = imgWidth - 50;
        MaxWidth = imgWidth;

        try
        {
            Color c;
            //Color c2;

            for (int i = 0; i < imgbox.Width; i++)
            {
                for (int j = 0; j < imgbox.Height; j++)
                {
                    c = imgbox.GetPixel(i, j);
                    string cn = c.Name;
                    counter++;
                    backgroundWorker1.ReportProgress(counter);
                }
            }
            MessageBox.Show("SUCESSFULLY DONE");
        }
        catch (Exception ex) { MessageBox.Show(ex.Message); }
    }

    private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        MyProgress.Value = e.ProgressPercentage;
    }

但是当我启动DoWork事件时.出现此错误

but when i started the DoWork event. this error showed up

BackgroundWorker声明不报告进度.
修改WorkerReportsProgess以声明它确实报告进度.

This BackgroundWorker states that it doesn't report progress.
Modify WorkerReportsProgess to state that it does report progress.

只需按照教程中的说明进行操作
有什么问题吗?我忘了什么吗?

ijust follow what the tutorial says
what would be the problem?, is there something that i forgot?

推荐答案

错误提示,请将BackgroundWorker组件的WorkerReportsProgress属性设置为true.

As the error suggests, set the WorkerReportsProgress property of your BackgroundWorker component to true.

这篇关于“此BackgroundWorker声明它不报告进度." - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆