本文整理匯總了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);
}
}