本文整理汇总了C#中Timer.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Timer.Update方法的具体用法?C# Timer.Update怎么用?C# Timer.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestReset
public void TestReset()
{
double duration = 0.79;
double subtract = 0.5;
Timer t = new Timer(duration);
t.Update(subtract);
t.Reset();
Assert.AreEqual(t.GetTimeLeft(), duration);
t.Update(duration);
t.Reset();
Assert.IsFalse(t.IsDone());
}
示例2: TestIsDone
public void TestIsDone()
{
double duration = 0.79;
Timer t = new Timer(duration);
t.Update(duration);
Assert.IsTrue(t.IsDone());
}
示例3: TestTimeLeft
public void TestTimeLeft()
{
double duration = 0.79;
double subtract = 0.5;
Timer t = new Timer(duration);
t.Update(subtract);
Assert.AreEqual(t.GetTimeLeft(), duration - subtract);
}
示例4: TestSet
public void TestSet()
{
double duration = 0.79;
double duration2 = 0.65;
double subtract = 0.5;
Timer t = new Timer(duration);
t.Update(subtract);
t.Set(duration2);
Assert.AreEqual(t.GetTimeLeft(), duration2);
t.Update(duration2);
t.Reset();
Assert.IsFalse(t.IsDone());
Assert.AreEqual(t.GetTimeLeft(), duration2);
Assert.AreEqual(t.Duration, duration2);
// Test that timespan works as well
TimeSpan d1 = new TimeSpan(123456);
t.Set(d1.TotalSeconds);
double tmp = t.Duration;
t.Set(d1);
Assert.AreEqual(tmp, t.Duration);
}
示例5: TestUpdate
public void TestUpdate()
{
TimeSpan duration = new TimeSpan(123456);
TimeSpan sub = new TimeSpan(1234);
Timer t = new Timer(duration);
Assert.IsTrue(t.Update(duration));
Assert.IsTrue(t.IsDone());
Assert.AreEqual(0, t.GetTimeLeft());
t.Reset();
Assert.IsTrue(t.Update(duration.TotalSeconds));
Assert.IsTrue(t.IsDone());
Assert.AreEqual(0, t.GetTimeLeft());
t.Reset();
Assert.IsFalse(t.Update(sub));
Assert.IsFalse(t.IsDone());
Assert.AreEqual(duration.TotalSeconds - sub.TotalSeconds, t.GetTimeLeft());
}