本文整理汇总了C#中System.Environment.TimeoutExponential方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.TimeoutExponential方法的具体用法?C# Environment.TimeoutExponential怎么用?C# Environment.TimeoutExponential使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Environment
的用法示例。
在下文中一共展示了Environment.TimeoutExponential方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Customer
private IEnumerable<Event> Customer(Environment env, string name, Resource counter, TimeSpan meanTimeInBank)
{
var arrive = env.Now;
env.Log("{0} {1}: Here I am", arrive, name);
using (var req = counter.Request()) {
// Wait for the counter or abort at the end of our tether
var timeout = env.TimeoutUniform(MinPatience, MaxPatience);
yield return req | timeout;
var wait = env.Now - arrive;
if (req.IsProcessed) {
// We got the counter
env.Log("{0} {1}: waited {2}", env.Now, name, wait);
yield return env.TimeoutExponential(meanTimeInBank);
env.Log("{0} {1}: Finished", env.Now, name);
} else {
// We reneged
env.Log("{0} {1}: RENEGED after {2}", env.Now, name, wait);
}
}
}
示例2: Source
private IEnumerable<Event> Source(Environment env, Resource counter)
{
for (int i = 0; i < NewCustomers; i++) {
var c = Customer(env, "Customer " + i, counter, TimeSpan.FromMinutes(12.0));
env.Process(c);
yield return env.TimeoutExponential(IntervalCustomers);
}
}