progress bar is not showing progress results?

匿名 (未验证) 提交于 2019-12-03 09:58:14

问题:

i have used progress bar in my application..my application is working fine but the progress bar is blank..it does not show the working progress what is wrong??

回答1:

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.



回答2:

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; }



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!