TimeElapsed without value

Thread is closed for posting
3 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 21 Jan 2008 Link to this post


    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.
  2. Sophy
    Sophy avatar
    636 posts

    Posted 21 Jan 2008 Link to this post


    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    
            //Stall the current thread for 0.1 seconds    

    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,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 21 Jan 2008 Link to this post


    I will try this.
Back to Top