This is a migrated thread and some comments may be shown as answers.

TimeElapsed without value

2 Answers 102 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 21 Jan 2008, 08:57 AM
Hello,

Using RadProgressManager to monitor a long server side process which inserts records in a db from a file I have a custom  radprogressarea with a progresstemplate and I want in my code to estimate the total process length.

So I try to get the TimeElapsed on each new record inserted to calculate an Estimated time.

But trying to get TimeElapsed I get null:
if (progress["TimeElapsed"] != null) is  never true.

but other Progress[xxx] values work and allow me to update my process.
and the client display the total elapsed time correctly ?

Is there a mismatch in the "TimeElpsed" value or is it only available clientside ?

Thanks for help.
CS

2 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 21 Jan 2008, 03:02 PM
Hi,

Thank you for contacting us.

The calculations related to the RadProgressArea are executed client-side. If you do not set them by yourself server-side their values will be null. As a workaround for your scenario we could suggest you find the TimeElapsed value server-side by yourself. You can achieve this if you get the datetime just before the progress monitoring loop starts and to subtract this datetime form the current datetime which you should get in every step inside the loop. Below is a sample code which demonstrates how to calculate the elapsed time:

private void UpdatesProgressContext(UploadedFile file)    
{            
        
    RadProgressContext progress = RadProgressContext.Current;  
    int total = 100;  
    DateTime startTime = DateTime.Now;  
    for (int i = 0; i < total; i++)    
    {    
        progress["SecondaryTotal"] = total.ToString();    
        progress["SecondaryValue"] = i.ToString();    
        progress["SecondaryPercent"] = i.ToString();  
         
        TimeSpan currentTime = DateTime.Now.Subtract(startTime);  
        progress["TimeElapsed"] = String.Format("{0:D2}:{1:D2}:{2:D2}", currentTime.Minutes, currentTime.Seconds, currentTime.Milliseconds);  
 
        if (!Response.IsClientConnected)    
        {    
            //Cancel button was clicked or the browser was closed, so stop processing    
            break;    
        }    
 
        //Stall the current thread for 0.1 seconds    
        System.Threading.Thread.Sleep(100);  
        
    }    

You can feel free to modify the suggested code so that it serves your needs.

Please, let us know if you need further assistance.

Best wishes,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
CSurieux
Top achievements
Rank 2
answered on 21 Jan 2008, 03:05 PM
Thanks,

I will try this.
CS
Tags
Upload (Obsolete)
Asked by
CSurieux
Top achievements
Rank 2
Answers by
Sophy
Telerik team
CSurieux
Top achievements
Rank 2
Share this question
or