等待窗体的制作

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

namespace  WaitForm
{
    
public partial class FrmMain : Form
    
{
        
private DataTable dt;
        
public FrmMain()
        
{
            InitializeComponent();
        }

        
public FrmMain(Thread th)
        
{
            InitializeComponent();
            
this.m_thWait = th;
        }

        
public static int m_number = 0;
        
private void FrmMain_Load(object sender, EventArgs e)
        
{
            dt 
= new DataTable();
            dt.Columns.Add(
"Name"typeof(string));
            dt.Columns.Add(
"Pwd"typeof(string));
            
if (m_thWait == null)
            
{
                
#region 初始化模拟数据 快捷键提示(当你敲入"#region"后请按"Tab"键2次,就会出现完整的#region#endregion字段范围)
                
                
for (int i = 0; i < 10; i++)
                
{
                    DataRow dr 
= dt.NewRow();
                    dr[
0= "name" + i;
                    dr[
1= i.ToString() + "-" + i.ToString();
                    dt.Rows.Add(dr);
                }

                
this.dgv.DataSource = dt;
                
#endregion

                
this.buttonQuery.Click += new EventHandler(buttonQuery_Click);
            }

            
else //选择查询按钮后触发
            {
                
                
this.buttonQuery.Visible = false;
                
for (int i = 0; i < 100000; i++)
                
{
                    m_number 
= i;
                    DataRow dr 
= dt.NewRow();
                    dr[
0= "name" + i;
                    dr[
1= i.ToString() + "-" + i.ToString();
                    dt.Rows.Add(dr);
                }

                
this.dgv.DataSource = dt;
                
try
                
{
                    
if (m_thWait != null)
                        m_thWait.Abort();
                }

                
catch (Exception ex)
                
{

                    MessageBox.Show(ex.Message);
                }

            }

                
this.buttonClose.Click += new EventHandler(buttonClose_Click);
           
        }


        
void buttonClose_Click(object sender, EventArgs e)
        
{
            
this.Close();
        }

        
private System.Threading.Thread m_thWait;
        
void buttonQuery_Click(object sender, EventArgs e)
        
{
            m_thWait 
= new Thread(run);
            
try
            
{
                m_thWait.Start();
                FrmMain frmResult 
= new FrmMain(m_thWait);
                frmResult.ShowDialog();
            }

            
catch (Exception ex)
            
{
                MessageBox.Show(ex.Message);
            }

        }

        
void run()
        
{
            FrmWait frmWait 
= new FrmWait();
            frmWait.ShowDialog();
        }


       
    }

}
using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;

namespace  WaitForm
{
    
public partial class FrmWait : Form
    
{
        
public FrmWait()
        
{
            InitializeComponent();
        }

        
//请测试者自己添加一个计数器
        private void timer1_Tick(object sender, EventArgs e)
        
{
            label1.Text 
= FrmMain.m_number.ToString();
        }

    }

}
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值