运行BackgroundWorker时主窗体控件不刷新

时间:2019-05-17 15:53:51

标签: c# backgroundworker

我的代码如下:

            if (!backgroundWorker1.IsBusy)
        {
            fastDataListView1.ClearObjects();
            fastDataListView1.DataSource = null;
            fastDataListView1.RebuildColumns();
            fastDataListView1.BackColor = Color.DarkGray;
            fastDataListView1.Refresh();
            fastDataListView1.Enabled = false;
            button1.Text = "Working...";
            button1.Enabled = false;
            fastDataListView1.Refresh();

            try
            {
                backgroundWorker1.RunWorkerAsync();
            }
            finally
            {

                fastDataListView1.BackColor = Color.White;
                fastDataListView1.Enabled = true;

                button1.Text = "Refresh Data...";
                button1.Enabled = true;
            }

后台工作程序运行正常,并获取了应有的数据。我的问题是,当我更改以下属性时,主窗体上的控件似乎没有更改:

            button1.Text = "Working...";

在开始后台工作之前。我可以拖动主要表单,它可以响应。我在做什么错了?

0 个答案:

没有答案