<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:將對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:實例化委托并調用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:讓子線程執行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) 評論(0)  編輯  收藏 所屬分類: .Net
    主站蜘蛛池模板: 国产精品免费在线播放| 67194熟妇在线永久免费观看| 人妖系列免费网站观看| 最好免费观看高清在线| 麻豆精品国产免费观看| 国产成A人亚洲精V品无码| 亚洲精品无码久久久久APP| 国精产品一区一区三区免费视频| 亚洲精品老司机在线观看| 亚洲午夜电影在线观看高清| eeuss草民免费| 在线播放亚洲第一字幕| 国产亚洲视频在线观看网址| 免费观看黄色的网站| 亚洲成AV人片在线观看ww| 少妇太爽了在线观看免费视频| 久久亚洲国产精品123区| 精品久久久久久亚洲综合网| 亚洲三级高清免费| 亚洲精品国产第1页| 精品国产麻豆免费人成网站| 亚洲精品高清一二区久久| 波霸在线精品视频免费观看| 免费大香伊蕉在人线国产| 久久国产亚洲电影天堂| 五月天婷婷免费视频| 亚洲AV永久无码区成人网站| jizz中国免费| 久久精品九九亚洲精品| 久久免费国产视频| 亚洲AV无码一区东京热久久| 久久精品免费全国观看国产| 亚洲av日韩aⅴ无码色老头| 女人18毛片a级毛片免费视频| 亚洲一级毛片在线观| 亚洲免费网站观看视频| 亚洲午夜电影在线观看高清| 免费少妇a级毛片人成网| 午夜影院免费观看| 国产精品亚洲专区在线播放| 亚洲卡一卡2卡三卡4卡无卡三|