开发者

progress bar is not showing progress results?

开发者 https://www.devze.com 2022-12-24 10:25 出处:网络
i have used progress bar in my a开发者_JS百科pplication..my application is working fine but the progress bar is blank..it does not show the working progress what is wrong??Probably you are performing

i have used progress bar in my a开发者_JS百科pplication..my application is working fine but the progress bar is blank..it does not show the working progress what is wrong??


Probably you are performing the work in the main GUI thread. This causes all GUI events to be delayed until the task is finished.

Use a BackgroundWorker instead and use its ProgressChanged event to update the progress bar.

Also remember to set WorkerReportsProgress to true on your background worker.


Refer this question of StackOverflow:

Updating DataGrid From a BackGroundWorker

I am assuming you must be accessing UI object using Invoke method.

If not try using following approach (Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.):


 //In Form.Designer.cs 

ProgressBar progressBar= new ProgressBar ();

//In code behind under Background worker method ProgressVlaueSetter SetProgressValueDel = SetProgressValue;
if (progressBar.InvokeRequired) {
progressBar.Invoke(SetProgressValueDel , 20); }

private delegate void ProgressVlaueSetter (intvalue);

//Set method invoked by background thread private void SetProgressValue(intvalue) { progressBar.Value= value; }


A compatible operating system and environment are prerequisites for a progress bar to work because the method of drawing the extending bar or blocks on the computer display is not compatible across all platforms. The progress bar type is protected and regulated and may be licensable but would not operate everywhere in a nation, state, province or even a city unless a specific type of progress indication is lawful. Moving code or an application to a different computer type or host system can be plagued with similar issues for other features.

0

精彩评论

暂无评论...
验证码 换一张
取 消