Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,
I am developing a system that requires I do some pretty big checkouts.

I am using sharpSVN to achieve this and it seems to work as expected. I am hooking up to the progress event in order to display a progress bar showing the progress of the checkout. My event handler is shown below


C#
private void UpdateProgressBar(object sender, SvnProgressEventArgs e)
{
    if (e.TotalProgress != -1)
    {
        mMakeProgressBar.Maximum = (int)e.TotalProgress;
    }
    mMakeProgressBar.Value = (int)e.Progress;
            
}


When this triggers I sometimes get values of e.progress greater than TotalProgress and often totalProgress remains at -1. Can anyone help as I am really starting o pull my hair out over this.


Thanks,
G
Posted

For sample code on how to do this, check the OnClientProgress method in the ProgressDialog in the AnkhSVN Source Code (username is "guest", no password).

There are a few oddities about the events that are generated by Subversion:

  • TotalProgress indicates the total size of the file being transferred. It is only set when the value is known, otherwise it is -1
  • Multiple requests can be active at the same time, so you see different combinations of TotalProgress and Progress. When combining this with the possible -1 value for unknown file size, it's quite hard to get an accurate estimation of throughput. This has been improved in Subversion 1.7 (and respective SharpSvn library). Progress values are accumulated for all events where TotalProgress == -1
  • It depends on the protocol (http(s):// vs svn://) and http handler (neon or serf) what part of the packets is indicated as Progress. You can't provide accurate network traffic, because you don't know the overhead.
 
Share this answer
 
Add the following line before setting the value :
C#
if ( e.Progress > e.TotalProgress ) mMakeProgressBar.Maximum = e.Progress + 1;
 
Share this answer
 
Comments
grafne79 24-Oct-11 9:54am    
On my version I had to cast the value to an int (sorry to be picky) i.e.
if ( e.Progress > e.TotalProgress ) mMakeProgressBar.Maximum = (int) e.Progress + 1;
grafne79 25-Oct-11 6:07am    
I have implemented this and the progress bar just sits at almost 100% for the majority of the time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900