Added ProgressToken timeRemaining
This commit is contained in:
parent
dc9e9e705c
commit
c3d62bd337
@ -7,6 +7,9 @@ public class ProgressToken
|
||||
public int incrementsCompleted { get; set; }
|
||||
public float progress => GetProgress();
|
||||
|
||||
public DateTime executionStarted { get; private set; }
|
||||
public TimeSpan timeRemaining => GetTimeRemaining();
|
||||
|
||||
public enum State { Running, Complete, Standby, Cancelled }
|
||||
public State state { get; private set; }
|
||||
|
||||
@ -16,6 +19,7 @@ public class ProgressToken
|
||||
this.increments = increments;
|
||||
this.incrementsCompleted = 0;
|
||||
this.state = State.Complete;
|
||||
this.executionStarted = DateTime.UnixEpoch;
|
||||
}
|
||||
|
||||
private float GetProgress()
|
||||
@ -25,6 +29,13 @@ public class ProgressToken
|
||||
return 0;
|
||||
}
|
||||
|
||||
private TimeSpan GetTimeRemaining()
|
||||
{
|
||||
if (increments > 0 && incrementsCompleted > 0)
|
||||
return DateTime.Now.Subtract(this.executionStarted).Divide(incrementsCompleted).Multiply(increments - incrementsCompleted);
|
||||
return TimeSpan.MaxValue;
|
||||
}
|
||||
|
||||
public void Increment()
|
||||
{
|
||||
this.incrementsCompleted++;
|
||||
@ -40,6 +51,7 @@ public class ProgressToken
|
||||
public void Start()
|
||||
{
|
||||
state = State.Running;
|
||||
this.executionStarted = DateTime.Now;
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
|
Loading…
Reference in New Issue
Block a user