C#進度條

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   os   sp   div   on   

進度條賦值

 1         public void SetProgressValue(int value) 2         { 3             if (this.InvokeRequired) 4             { 5                 Action<Int32> stepHandle = new Action<int>(SetProgressValue); 6                 this.Invoke(stepHandle, new object[] { value }); 7             } 8             else 9             {10                 this.progressBarOfCreateDatabase.Value = value;11                 this.label1.Text = "初始化中 :" + value.ToString() + "%";12                 if (value == this.progressBarOfCreateDatabase.Maximum) this.Close();13             }14         }

耗時操作

 1         void ThreadStartCallback() 2         { 3             Action createCallback = SDYF.TCRC.Bussiness.Commander.CreateDB;//耗時操作 4             IAsyncResult asyncResult = createCallback.BeginInvoke(null, null); 5             Int32 i = 0; 6             while (!asyncResult.IsCompleted) 7             { 8                 if (i < 99) 9                 {10                     i++;11                 }12                 Thread.Sleep(40);13                 SetProgressValue(i);14             }15             SetProgressValue(100);16         }

開啟線程

1         private void CreateDatabase_Load(object sender, EventArgs e)2         {3             new System.Threading.Thread(new System.Threading.ThreadStart(ThreadStartCallback)).Start();4         }

 

C#進度條

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.