<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    step1:定義委托
    private delegate void loadingRun(int step);

    step2:將對(duì)UI的操作封裝成方法
    private void doUpdate(int step)
            {
                
    if (step == 1)
                {
                    
    this.checkBox1.Checked = true;
                    
    this.checkBox1.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.checkBox2.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                }
                
    else if (step == 2)
                {
                    
    this.checkBox2.Checked = true;
                    
    this.checkBox2.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.checkBox3.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                }
                
    else if (step == 3)
                {
                    
    this.checkBox3.Checked = true;
                    
    this.checkBox3.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.checkBox4.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                }
                
    else if (step == 4)
                {
                    
    this.checkBox4.Checked = true;
                    
    this.checkBox4.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.Close();
                }
            }

    step3:實(shí)例化委托并調(diào)用doUpdate
    public void run()
            {
                loadingRun load 
    = new loadingRun(doUpdate);

                
    //do something

                
    this.Invoke(load, 1);

                
    //do something

                
    this.Invoke(load, 2);

                
    //do something

                
    this.Invoke(load, 3);

                
    //do something

                
    this.Invoke(load, 4);
            }

    step4:讓子線程執(zhí)行run
    private void init()
            {
                ThreadStart ts 
    = new ThreadStart(run);
                Thread runThread 
    = new Thread(ts);
                runThread.Start();
            }

    ========================================分割線=============以下為完整代碼============================================
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;

    namespace WindowsFormsApplication1
    {
        
    public partial class LoadingTest : Form
        {
            
    private delegate void loadingRun(int step);

            
    public LoadingTest()
            {
                InitializeComponent();
                init();
            }

            
    private void init()
            {
                ThreadStart ts 
    = new ThreadStart(run);
                Thread runThread 
    = new Thread(ts);
                runThread.Start();
            }

            
    public void run()
            {
                loadingRun load 
    = new loadingRun(doUpdate);

                
    //do something

                
    this.Invoke(load, 1);

                
    //do something

                
    this.Invoke(load, 2);

                
    //do something

                
    this.Invoke(load, 3);

                
    //do something

                
    this.Invoke(load, 4);
            }

            
    private void doUpdate(int step)
            {
                
    if (step == 1)
                {
                    
    this.checkBox1.Checked = true;
                    
    this.checkBox1.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.checkBox2.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                }
                
    else if (step == 2)
                {
                    
    this.checkBox2.Checked = true;
                    
    this.checkBox2.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.checkBox3.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                }
                
    else if (step == 3)
                {
                    
    this.checkBox3.Checked = true;
                    
    this.checkBox3.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.checkBox4.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                }
                
    else if (step == 4)
                {
                    
    this.checkBox4.Checked = true;
                    
    this.checkBox4.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
                    
    this.Close();
                }
            }
        }
    }

    posted on 2011-09-21 10:24 Ying-er 閱讀(422) 評(píng)論(0)  編輯  收藏 所屬分類: .Net
    主站蜘蛛池模板: 成人a毛片免费视频观看| 国产乱弄免费视频| 最近免费字幕中文大全| 亚洲国产成人手机在线观看| 久久综合日韩亚洲精品色| 免费播放特黄特色毛片| 成年女人毛片免费播放视频m| 久久久久成人精品免费播放动漫| 美女视频黄频a免费| 中文字幕乱码亚洲精品一区| 亚洲成电影在线观看青青| 亚洲AV日韩AV鸥美在线观看| 亚洲一级特黄大片在线观看| 国产大片91精品免费看3| 久久精品网站免费观看| 免费能直接在线观看黄的视频 | 99精品免费观看| 中文字幕乱理片免费完整的| 特级毛片aaaa免费观看| 羞羞视频在线免费观看| 亚洲精品宾馆在线精品酒店| 亚洲日本va在线观看| 亚洲国产精品乱码在线观看97| 西西人体44rt高清亚洲| 国产亚洲精品自在久久| 亚洲精品字幕在线观看| 夜夜春亚洲嫩草影院| 伊人久久亚洲综合| 国产成人精品日本亚洲专区61| 亚洲美日韩Av中文字幕无码久久久妻妇| 国产婷婷高清在线观看免费| 四虎永久在线精品免费影视| 国产传媒在线观看视频免费观看| 拔擦拔擦8x华人免费久久| 国产成人免费全部网站| 免费jlzzjlzz在线播放视频| 又粗又大又硬又爽的免费视频| 免费国产a国产片高清网站| 亚洲 国产 图片| 中文字幕第一页亚洲| 亚洲αv在线精品糸列|