Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Progress Bar Problem
 

Progress Bar Problem

Hi All

I have the following propblem:

I have an applicaion with VB.Net 2005, and I use the ProgressBar Controlin "Blocks" styleI want thisProgressBar to the progress of the process which is running step by step.

how to do this ??

should i know the process execution timetocalculatethe step size ??

i mean by the step size :


the progress bar has a minimum value and a maximum value an a value attribute which is incresing by the progress of the process, like this


ProgressBar1.Value += 10


10 is the step size i am working with


how to estimate this value ?

debuging  Tuesday, February 10, 2009 7:03 AM
Isn't there some way for you to estimate how far along you are in your task? What is the task you are measuring progress on? For example, if you are processing 140 files, it would be reasonable to create a counter and for you to fire the OnProgress event after every 14 files are processed.
omarazam  Wednesday, February 11, 2009 8:29 PM

my process is only one line of code, this line call a SQL stored procedure and this procedure take many seconds.

debuging  Thursday, February 12, 2009 8:08 AM

Hi Debuging,

> my process is only one line of code, this line call a SQL stored procedure and this procedure take many seconds.

You can test out the time it takes for SQL stored procedure to execute generally first, e.g. 10 seconds. Use a timer in your application and set the Interval to 1000. When the timer ticks for the first time, set thevalue of the ProgressBar to 10%; when it ticks for the second time, set the value to 20% and so on.

Alternatively, you can set the Style property of the ProgressBar to Marquee when the stored procedure begins executing. When it finishes, set the value of the PropgressBar to 100% and the Style property to Block.

Hope this helps.
If you have any question, please feel free to letme know.

Sincerely,
Linda Liu

Linda Liu  Friday, February 13, 2009 7:49 AM
Hi Linda

My problem is to test out the time it takes for SQL stored procedure, I dont know how to get that time. Also there is some processes not in SQL and also take many seconds like a function in VB does some operation and take many seconds.

My problem is how to get the expected process time that it will take to set my progressbar step.

I hope you got waht I want to do.


Thanks for your help.
debuging  Saturday, February 14, 2009 8:23 AM

Hi Debuging,

Thank you for your reply!

> My problem is how to get the expected process time that it will take to set my progressbar step.

A simple way is to use the DateTime.Nowproperty to record the start time and end time and then calculate the time span. For example:

DateTime start = DateTime.Now;
// your code to test
....
DateTime end = DateTime.Now;
// this is the elapsed time
TimeSpan ts = end.Subtract(start);

In addition, you can use System.Diagnostics.Stopwatch to measure elapsed time. For example:

Stopwatch
sw = new Stopwatch();
sw.Start();
// your code to test
....

sw.Stop();
TimeSpan ts = sw.Elapsed;

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

Linda Liu  Monday, February 16, 2009 4:32 AM
Hi Linda

I think you did not get myproblem. I don't have the end time of the process, what I wantis tocalculate the process timelength before it starts.

My problem is to get the execution for SQL stored procedure, I dont know how to get that time. The stored procedure may exist on a local server or on a remote server , so the time will be variant. I cannot make a stop watch for only one case and give a static value for the step .

My Question is CanI get the execution time of stored procedure before execution regarding that server can be local or remote??




I hope you got my problem.



Thanks for your help.
debuging  Monday, February 16, 2009 1:00 PM

Hi Debuging,

> I cannot make a stop watch for only one case and give a static value for the step .

This is justthe suggestion I made to you. Test out the approx time it takes the process to complete in advance and thenuse that as a static value in your application.

> My Question is CanI get the execution time of stored procedure before execution regarding that server can be local or remote??

I'm afraid there's no way to do this.

Well, you've mentioned that there'realsosome functions in your application that will take many seconds to execute. If you want to show the execution progress ofthe Stored Procedure and the time-consuming functions, you can estimate that the execution of the Stored Procedure will take half timeit takes forthe whole process and set the value of the progressbar to 50% when the Stored Procedure finishes. When the fucntions finish, set the value of the progressbar to 100%.

In addition, you can set the Style property of the progressbar to Marquee so that you needn't calculate the execution time. Whenthe whole processfinishes, set the value of the PropgressBar to 100% and the Style property to Block.

Hope this helps.

Sincerely,
Linda Liu

Linda Liu  Tuesday, February 17, 2009 2:51 AM
cluster again your sql procedure into some pieces

in the code u call that procedure step by step.

here u can move the progress bar block each step.
Gardenia
Angel Moon  Wednesday, February 18, 2009 5:55 AM

You can use google to search for other answers

Custom Search

More Threads

• Docking and Anchoring Issues
• BUG?! Visual Studio .NET 2003: Why is a Modal Dialog destroyed?
• Context Help in C#
• Please Help !!!
• Loading panels too slow
• Setting default text property
• Newbie Question
• Collapsible property for custom control
• Problem with designer in VS 2005 Beta 2
• PropertyGrid How do you dectect the close of the Editor