C 多執行緒使用progressBar進度條控制項

2021-05-27 02:31:47 字數 706 閱讀 6498

該例子對為多執行緒使用progressbar的乙個簡單例子。

實現:(1)計算progressbar執行時間(既進度條開始到結束的時間)

(2)利用多執行緒執行(用這個應該必須用多執行緒吧,否則沒什麼實際意義,因為你有進度條必然是要做其他的事情給予乙個進度提示)

大概就如下圖了:

完整**如下:

引入命名空間:

using system.threading;
完整**:

namespace progressbar

datetime dt; //記時

private void btnstart_click(object sender, eventargs e)

private delegate void dodatadelegate(object number);

/// /// 進行迴圈

///

///

private void dodata(object number)

else

messagebox.show(datetime.now.subtract(dt).tostring()); //迴圈結束截止時間}}

private void btnclear_click(object sender, eventargs e)}}

c 中使用多執行緒

using system using system.drawing using system.collections using system.componentmodel using system.windows.forms using system.data using system.threa...

c 中使用多執行緒

using system using system.drawing using system.collections using system.componentmodel using system.windows.forms using system.data using system.threa...

C 多執行緒的使用

引入命名空間 using system.threading 方式1 手動建立執行緒 開啟多執行緒執行任務 thread thread1 new thread a thread1.start thread thread2 new thread a thread2.start thread thread...