1.首先建立乙個winform窗體,可講窗體的formborderstyle屬性設定為"none",將窗體的標題欄去掉。窗體中可放乙個picturebox控制項和兩個label控制項。其中picturebox控制項存放載入等待的。乙個label控制項可放置text文字。
winform**如下:
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 testprivate delegate
void
settexthandler
(string text);
public
void
settext
(string text)
else}}
}2.新建乙個類waitformservice,**如下「
using system;using system.collections.generic;
using system.text;
using system.threading;
using system.windows.forms;
namespace test
public static
void
closewaitform
()public static
void
setwaitformcaption
(string text)
private static waitformservice _instance;
private static readonly object synclock =
newobject
();public static waitformservice instance
}}return waitformservice._instance;}}
private
waitformservice
()private thread waitthread;
private waitform waitform;
public
void
createform
()catch
(exception)
} waitthread =
newthread
(new
threadstart
(delegate
()));
waitthread.
start
();}
public
void
closeform
()catch
(exception)}}
public
void
setformcaption
(string text)
catch
(exception)}}
}}3.呼叫如下:
trycatch
(exception ex)
C winform 多執行緒中建立等待窗體
1.首先建立乙個winform窗體,可講窗體的formborderstyle屬性設定為 none 將窗體的標題欄去掉。窗體中可放乙個picturebox控制項和兩個label控制項。其中picturebox控制項存放載入等待的。乙個label控制項可放置text文字。winform 如下 using...
c winform中多執行緒的使用
其實我主要就打算記錄兩個點。第乙個是關於大量任務下窗體的等待效果,或者說人機互動的友好性。關於這一點,我在網上也搜了相關的資料,但是發現都寫的大同小異。所以本文以乙個例子為基礎,整理出乙個彈框進度條提示的效果案例。同時我個人覺得這個案例的擴充套件和 簡潔性相對較好。廢話不多說,直接擼 如下圖所示的,...
C winform程式設計中多執行緒操作控制項方法
1 private void form1 load object sender,eventargs e 27 8 9 定義乙個 10 11private delegate void crossthreadoperationcontrol 1213 private void backgroundpro...