想在核对数据时,加一个弹出窗口说明“正在处理,请稍等...”,
从网上找了一下,基本都是用线程解决,我也试了,没成功,主要不会!  
请帮忙!谢谢 !

解决方案 »

  1.   


            //进度条
            private System.Windows.Forms.ProgressBar progressBar1;
    /**
     * 必需的设计器变量。
     */
    private System.ComponentModel.Container components = null;
    private boolean bStart = true;
           
           private delegate void StartSyncSqrDelegate(int i,int dvalue);
    private void DlgWait_Load (Object sender, System.EventArgs e)
    {
    StartShowLoadDataProgress();
    }
    public void StartShowLoadDataProgress()
    {
    try
    {
    System.Threading.Thread th2 = new System.Threading.Thread(new System.Threading.ThreadStart(StartProgressBar)); 
    th2.Start(); 

    }
    catch(Exception e1)
    {

    }
    }
    /// <summary>
    /// 主程序显示下载进度
    /// </summary>
    private void StartProgressBar()
    {
    this.progressBar1.set_Maximum(100);
    this.progressBar1.set_Minimum(0);
    int i=0;
    while(bStart)
    {

    this.progressBar1.set_Value(i);
    i++;
    if(i > 100)
    {
    i = 0;
    }
    System.Threading.Thread.Sleep(50);

    }
    } private void DlgWait_Closing (Object sender, System.ComponentModel.CancelEventArgs e)
    {
    bStart = false;
    System.Threading.Thread.Sleep(50);
    }
      

  2.   

    肯定要用多线程操作,
    数据处理放到线程中,如以下:
    private delegate void setvisible(Control control, bool visible); private void SetControlVisible(Control control, bool visible)
            {
                try
                {
                    if (control.InvokeRequired)
                    {
                        SetComVisible setVisible = new SetComVisible(SetControlVisible);
                        // this.Invoke(setVisible,new object[]{visible});
                        control.Invoke(setVisible, new object[] { control, visible });
                    }
                    else
                    {
                        Application.DoEvents();
                        control.Visible = visible;
                        Application.DoEvents();
                    }
                }
                catch
                { }
            }private void LoadData()
    {
    SetControlVisible(label, true);
    ///dataprocess  你的数据处理
    SetControlVisible(label, false);
    }form_load()
    {
    label.text = "处理中,请稍候!";Thread t = new Thread(new TreadStart(LoadData))
    t.Start();
    }
      

  3.   

    多线程访问界面中的控件一定要用delegate异步,否则是会出错,以上说明很清楚,希望对你有帮助