Hi Han,
I don't think you understood me. I'll try to be more specific.
The progress that you see on the screen in the ProgressArea, is only updated inside the for loop. There you set explicitly the number of "transferred items", the number of "remaining items", the remaining time etc. Any actions or methods outside the loop won't register in the ProgressArea. To update it, you have to set all the properties
manually at equal (if possible) intervals.
I'll try to explain it with an example. Say you have a method that goes through a list of integer numbers and adds their sum. Here's how you can monitor the process of this method:
aspx.
cs.
private
static
Random rand =
new
Random();
List<
int
> numbers =
new
List<
int
>();
protected
void
Page_Load(
object
sender, System.EventArgs e)
{
for
(
int
i = 0; i < 400; i++)
{
numbers.Add(rand.Next(0, 400));
}
RadProgressArea1.Localization.Uploaded =
"Total Progress"
;
RadProgressArea1.Localization.UploadedFiles =
"Progress"
;
RadProgressArea1.Localization.CurrentFileName =
"Custom progress in action: "
;
}
protected
void
buttonSubmit_Click(
object
sender, System.EventArgs e)
{
Label2.Text = SumNumbers(numbers).ToString();
}
private
int
SumNumbers(List<
int
> numbers)
{
int
total = numbers.Count;
int
sum = 0;
RadProgressContext progress = RadProgressContext.Current;
progress.Speed =
"N/A"
;
for
(
int
i = 0; i < total; i++)
{
sum += numbers[i];
progress.PrimaryTotal = 1;
progress.PrimaryValue = 1;
progress.PrimaryPercent = 100;
progress.SecondaryTotal = total;
progress.SecondaryValue = i;
progress.SecondaryPercent = (i*100)/total;
progress.CurrentOperationText =
"Step "
+ i.ToString();
if
(!Response.IsClientConnected)
{
//Cancel button was clicked or the browser was closed, so stop processing
break
;
}
progress.TimeEstimated = (total - i) * 100;
//Stall the current thread for 0.1 seconds
System.Threading.Thread.Sleep(30);
}
return
sum;
}
Please note that the updating of the process happens inside the monitored method itself.
Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their
blog feed now