winform一个技术有关问题,困扰一阵子了,界面刷新的有关问题

winform一个技术问题,困扰一阵子了,界面刷新的问题
winform程序,优化界面,从主窗体弹出一个索引窗体A(非模态),索引窗体选取索引条件后,点击“确认”按钮,

1、开启一个定时器(线程也试过或者直接new也试过结果一样)new另外一个窗体R显示结果,等待R数据加载完毕后A关闭,显示R
2、在等待R加载数据的同时,A窗体启用一个定时器读取一个全局变量(进度),更新“确认”按钮上的文字,5%,10%。。。。。。提示用户执行进度。

2个窗体都是非模态的,用show()显示。

结果

1、R窗口能正常显示检索结果
2、界面A上按钮上的文字无法更新。

执行刷新的函数就是,
btn.text="5%"
btn.refresh();


在网上搜索和跟踪调试目前已经得知以下结果:

1、怀疑是R窗体加载数据量大导致A窗体无法响应刷新,增加application.doevent(),稍微sleep(100);  都无效果,注释掉窗体R中加载数据的函数,问题依旧。
2、怀疑是非ui线程更新界面的委托问题,增加了委托问题依旧。Debug模式下跟踪发现定时器每次都执行了刷新,按钮变量的“Text”属性已经发生更改,但是就是没有在界面上显示更新。
3、注释掉开启结果窗体R的定时器(不开启窗体R)。A窗体上按钮文字开始正常刷新。

4、传递A窗体变量给R,在R窗体加载过程中边加载边刷新,也无法实现效果。


究竟什么问题呢。请给位老师给予指点,谢谢了。
------解决方案--------------------
把控制代码写在第一个窗体里

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 subForm2 = new Form2();
            subForm2.parentForm = this;
            subForm2.Show();
            subForm2.Start();
        }
        public void Show(string content)
        {
            this.button1.Text = content;
        }

    }
}





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace WindowsFormsApplication2
{
    public partial class Form2 : Form
    {
        public object parentForm;

        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
           
        }
        public void Start()
        {
            if (parentForm == null)
                return;
            Form1 form1 = (Form1)parentForm;
            for (int i = 0; i < 10000; i++)
            {
                form1.Show(i.ToString());
                Thread.Sleep(1000);
                Application.DoEvents();
            }
        }
    }
}




------解决方案--------------------
取消掉想当然的“全局变量”而再重新设计,你就接近我们平常的设计了。