repo: Move progress interval logic to base class
This commit is contained in:
parent
90cb3849b5
commit
03db2a2f09
|
@ -183,9 +183,6 @@ namespace SparkleLib {
|
||||||
double percentage = 1.0;
|
double percentage = 1.0;
|
||||||
Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
|
Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
|
||||||
|
|
||||||
DateTime last_change = DateTime.Now;
|
|
||||||
TimeSpan change_interval = new TimeSpan (0, 0, 0, 1);
|
|
||||||
|
|
||||||
while (!git.StandardError.EndOfStream) {
|
while (!git.StandardError.EndOfStream) {
|
||||||
string line = git.StandardError.ReadLine ();
|
string line = git.StandardError.ReadLine ();
|
||||||
Match match = progress_regex.Match (line);
|
Match match = progress_regex.Match (line);
|
||||||
|
@ -218,14 +215,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (number >= percentage) {
|
if (number >= percentage) {
|
||||||
percentage = number;
|
percentage = number;
|
||||||
|
|
||||||
if (percentage == 100.0)
|
|
||||||
percentage = 99.0;
|
|
||||||
|
|
||||||
if (DateTime.Compare (last_change, DateTime.Now.Subtract (change_interval)) < 0) {
|
|
||||||
base.OnSyncProgressChanged (percentage, speed);
|
base.OnSyncProgressChanged (percentage, speed);
|
||||||
last_change = DateTime.Now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,9 +239,6 @@ namespace SparkleLib {
|
||||||
double percentage = 1.0;
|
double percentage = 1.0;
|
||||||
Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
|
Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
|
||||||
|
|
||||||
DateTime last_change = DateTime.Now;
|
|
||||||
TimeSpan change_interval = new TimeSpan (0, 0, 0, 1);
|
|
||||||
|
|
||||||
while (!git.StandardError.EndOfStream) {
|
while (!git.StandardError.EndOfStream) {
|
||||||
string line = git.StandardError.ReadLine ();
|
string line = git.StandardError.ReadLine ();
|
||||||
Match match = progress_regex.Match (line);
|
Match match = progress_regex.Match (line);
|
||||||
|
@ -284,14 +271,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (number >= percentage) {
|
if (number >= percentage) {
|
||||||
percentage = number;
|
percentage = number;
|
||||||
|
|
||||||
if (percentage == 100.0)
|
|
||||||
percentage = 99.0;
|
|
||||||
|
|
||||||
if (DateTime.Compare (last_change, DateTime.Now.Subtract (change_interval)) < 0) {
|
|
||||||
base.OnSyncProgressChanged (percentage, speed);
|
base.OnSyncProgressChanged (percentage, speed);
|
||||||
last_change = DateTime.Now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -634,16 +634,26 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private DateTime progress_last_change = DateTime.Now;
|
||||||
|
private TimeSpan progress_change_interval = new TimeSpan (0, 0, 0, 1);
|
||||||
|
|
||||||
protected void OnSyncProgressChanged (double progress_percentage, string progress_speed)
|
protected void OnSyncProgressChanged (double progress_percentage, string progress_speed)
|
||||||
{
|
{
|
||||||
// Console.WriteLine ("OnProgressChanged: " + progress_percentage + " " + progress_speed);
|
if (DateTime.Compare (this.progress_last_change,
|
||||||
|
DateTime.Now.Subtract (this.progress_change_interval)) < 0) {
|
||||||
|
|
||||||
|
if (SyncProgressChanged != null) {
|
||||||
|
if (progress_percentage == 100.0)
|
||||||
|
progress_percentage = 99.0;
|
||||||
|
|
||||||
this.progress_percentage = progress_percentage;
|
this.progress_percentage = progress_percentage;
|
||||||
this.progress_speed = progress_speed;
|
this.progress_speed = progress_speed;
|
||||||
|
this.progress_last_change = DateTime.Now;
|
||||||
|
|
||||||
if (SyncProgressChanged != null)
|
|
||||||
SyncProgressChanged (progress_percentage, progress_speed);
|
SyncProgressChanged (progress_percentage, progress_speed);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Creates a SHA-1 hash of input
|
// Creates a SHA-1 hash of input
|
||||||
|
|
Loading…
Reference in a new issue