本文整理汇总了C#中IEnvironment.Timeout方法的典型用法代码示例。如果您正苦于以下问题:C# IEnvironment.Timeout方法的具体用法?C# IEnvironment.Timeout怎么用?C# IEnvironment.Timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnvironment
的用法示例。
在下文中一共展示了IEnvironment.Timeout方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Worker
static IEnumerable<IEvent> Worker(IEnvironment env)
{
Console.WriteLine("{0}: Carico la macchina...",
env.Now);
yield return env.Timeout(LoadTime);
env.Exit(env.Random.Choice(Tasks));
}
示例2: Machine
static IEnumerable<IEvent> Machine(IEnvironment env)
{
while (true) {
var worker = env.Start(Worker(env));
yield return worker;
Console.WriteLine("{0}: Eseguo il comando {1}",
env.Now, worker.Value);
yield return env.Timeout(WorkTime);
}
}
示例3: Train
static IEvents Train(IEnvironment env)
{
object cause;
string fmt;
while (true) {
var time = env.Random.Exponential(1.0/AvgTravelTime);
fmt = "Treno in viaggio per {0:.00} minuti";
Console.WriteLine(fmt, time);
yield return env.Timeout(time);
if (env.ActiveProcess.Interrupted(out cause))
break;
fmt = "Arrivo in stazione, attesa passeggeri";
Console.WriteLine(fmt);
yield return env.Timeout(2.Minutes());
if (env.ActiveProcess.Interrupted(out cause))
break;
}
fmt = "Al minuto {0:.00}: {1}";
Console.WriteLine(fmt, env.Now, cause);
}
示例4: Person
static IEvents Person(IEnvironment env,
string gender,
IResource toilet)
{
using (var req = toilet.Request()) {
yield return req;
Console.WriteLine("{0:0.00}: {1} --> Bagno",
env.Now, gender);
var t = env.Random.Exponential(1.0/AvgTimeInToilet);
yield return env.Timeout(t);
Console.WriteLine("{0:0.00}: {1} <-- Bagno",
env.Now, gender);
}
}
示例5: PersonGenerator
static IEvents PersonGenerator(IEnvironment env)
{
var womenToilet = env.NewResource(1);
var menToilet = env.NewResource(1);
var count = 0;
while (true) {
var rnd = env.Random.NextDouble();
var gn = ((rnd<0.5) ? "Donna" : "Uomo") + count++;
var tt = (rnd<0.5) ? womenToilet : menToilet;
Console.WriteLine("{0:0.00}: {1} in coda",
env.Now, gn);
env.Start(Person(env, gn, tt));
var t = env.Random.Exponential(1.0/AvgPersonArrival);
yield return env.Timeout(t);
}
}
示例6: PastaCook
static IEnumerable<IEvent> PastaCook(IEnvironment env)
{
while (true) {
var cookTime = env.Random.Normal(AvgCookTime,
StdCookTime);
var fmt = "Pasta in cottura per {0} minuti";
Console.WriteLine(fmt, cookTime);
yield return env.Timeout(cookTime);
if (cookTime < AvgCookTime - StdCookTime)
Console.WriteLine("Pasta poco cotta!");
else if (cookTime > AvgCookTime + StdCookTime)
Console.WriteLine("Pasta troppo cotta...");
else
Console.WriteLine("Pasta ben cotta!!!");
}
}
示例7: NewTarget
static ITimeout<string> NewTarget(IEnvironment env)
{
var delay = env.Random.DiscreteUniform(1, 20);
var target = env.Random.Choice(Targets);
return env.Timeout(delay, target);
}
示例8: AProcess
static IEnumerable<IEvent> AProcess(IEnvironment env)
{
yield return env.Timeout(7);
env.Exit("VAL_P");
}
示例9: EmergencyBrake
static IEvents EmergencyBrake(IEnvironment env,
IProcess train)
{
yield return env.Timeout(BreakTime);
train.Interrupt("FRENO EMERGENZA");
}
示例10: DoSucceed
static IEnumerable<IEvent> DoSucceed(IEnvironment env,
IEvent<object> ev)
{
yield return env.Timeout(5);
ev.Succeed("SI :)");
}
示例11: DoFail
static IEnumerable<IEvent> DoFail(IEnvironment env,
IEvent<object> ev)
{
yield return env.Timeout(5);
ev.Fail("NO :(");
}