本文整理汇总了C#中IEnvironment.Start方法的典型用法代码示例。如果您正苦于以下问题:C# IEnvironment.Start方法的具体用法?C# IEnvironment.Start怎么用?C# IEnvironment.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnvironment
的用法示例。
在下文中一共展示了IEnvironment.Start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Proc
static IEnumerable<IEvent> Proc(IEnvironment env)
{
var ev1 = env.Event();
env.Start(DoSucceed(env, ev1));
yield return ev1;
if (ev1.Succeeded)
Console.WriteLine(ev1.Value);
var ev2 = env.Event();
env.Start(DoFail(env, ev2));
yield return ev2;
if (ev2.Failed)
Console.WriteLine(ev2.Value);
}
示例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: CondTester
static IEnumerable<IEvent> CondTester(IEnvironment env)
{
var t1 = env.NamedTimeout(5, "VAL_T", "T");
var aProc = env.Start(AProcess(env), name: "P");
var cond = env.AllOf(t1, aProc);
yield return cond;
Console.WriteLine("ALL: {0}", cond.Value);
var t2 = env.NamedTimeout(5, "VAL_T", "T");
aProc = env.Start(AProcess(env), name: "P");
cond = env.AnyOf(t2, aProc);
yield return cond;
Console.WriteLine("ANY: {0}", cond.Value);
aProc = env.Start(AProcess(env), name: "P");
var aTime = env.NamedTimeout(5, "VAL_T", "T");
ConditionEval<ITimeout<string>, IProcess> pred =
c => c.Ev1.Succeeded && c.Ev2.Succeeded &&
c.Ev1.Value.Equals("VAL_T") &&
c.Ev2.Value.Equals("VAL_P");
cond = env.Condition(aTime, aProc, pred);
yield return cond;
Console.WriteLine("CUSTOM: {0}", cond.Value);
}
示例4: 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);
}
}