本文整理匯總了C#中System.Environment.TimeoutD方法的典型用法代碼示例。如果您正苦於以下問題:C# Environment.TimeoutD方法的具體用法?C# Environment.TimeoutD怎麽用?C# Environment.TimeoutD使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Environment
的用法示例。
在下文中一共展示了Environment.TimeoutD方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Cast
private IEnumerable<Event> Cast(Environment env, Resource crane, string name, IEnumerable<Slab> castQueue)
{
foreach (var slab in castQueue) {
yield return env.TimeoutD(slab.CastTime);
env.Log("Caster {0} finished at {1}", name, env.Now);
var token = crane.Request();
yield return token;
env.Process(Transport(env, crane, token, name));
}
}
示例2: TestRunResumeDApi
public void TestRunResumeDApi()
{
/* Stopped simulation can be resumed. */
var env = new Environment(defaultStep: TimeSpan.FromMinutes(1));
var events = new List<Event>() {
env.TimeoutD(5),
env.TimeoutD(10),
env.TimeoutD(15),
env.TimeoutD(20)
};
Assert.AreEqual(env.NowD, 0);
Assert.AreEqual(env.PeekD(), 5);
Assert.IsFalse(events.Any(x => x.IsProcessed));
env.RunD(10);
Assert.AreEqual(env.NowD, 10);
Assert.AreEqual(env.PeekD(), 10);
Assert.IsTrue(events[0].IsProcessed);
Assert.IsFalse(events[1].IsProcessed);
Assert.IsFalse(events[2].IsProcessed);
env.RunD(5);
Assert.AreEqual(env.NowD, 15);
Assert.AreEqual(env.PeekD(), 15);
Assert.IsTrue(events[0].IsProcessed);
Assert.IsTrue(events[1].IsProcessed);
Assert.IsFalse(events[2].IsProcessed);
env.RunD(1);
Assert.AreEqual(env.NowD, 16);
Assert.AreEqual(env.PeekD(), 20);
Assert.IsTrue(events[0].IsProcessed);
Assert.IsTrue(events[1].IsProcessed);
Assert.IsTrue(events[2].IsProcessed);
env.RunD();
Assert.AreEqual(env.NowD, 20);
Assert.AreEqual(env.PeekD(), double.MaxValue);
}
示例3: AProcess
private static IEnumerable<Event> AProcess(Environment env, List<string> log)
{
while (env.NowD < 2) {
log.Add(env.NowD.ToString("00", CultureInfo.InvariantCulture.NumberFormat));
yield return env.TimeoutD(1);
}
}
示例4: Transport
private IEnumerable<Event> Transport(Environment env, Resource crane, Request token, string caster)
{
env.Log("Crane transporting from caster {0} at {1}", caster, env.Now);
yield return env.TimeoutD(4);
crane.Release(token);
}
示例5: TestOperatorAndBlockedProcess
private IEnumerable<Event> TestOperatorAndBlockedProcess(Environment env)
{
var timeout = env.TimeoutD(1);
var @event = new Event(env);
yield return env.TimeoutD(1);
var condition = timeout & @event;
Assert.IsFalse(condition.IsTriggered);
}
示例6: TestAndConditionBlockedProcess
private IEnumerable<Event> TestAndConditionBlockedProcess(Environment env)
{
var t1 = env.TimeoutD(1);
var e = new Event(env);
yield return t1;
yield return t1 & e;
Assert.Fail("Process should not recover");
}