本文整理汇总了C#中Process.Delay方法的典型用法代码示例。如果您正苦于以下问题:C# Process.Delay方法的具体用法?C# Process.Delay怎么用?C# Process.Delay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process.Delay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generator
private IEnumerator<Task> Generator(Process Self, object Data)
{
// initialize
SimResult.Init();
foreach (var line in Bus.Values)
{
long Offset = 0;
foreach (var bus in line)
{
bus.Activate(null,Offset);
Offset += Config.BusInterval;
}
}
IntervalRate.Mean = 60; // 60s as random step time expectation
IntervalRate.StandardDeviation = 30; // +- 30s around 60s
var rd = new Random();
// loop
while(Now<RunTime)
{
int Step = Interval;
ArrivalRate.Mean = 1 * Step / 60.0; // 1 passenger per 60s
foreach (var B in CityMap.BusStops.Values)
{
int Count = Arrival;
for (int i=0; i<Count;i++)
{
string[] SelectedLine = { "" };
SelectedLine = CityMap.Lines[1];
do
{
SelectedLine = CityMap.Lines[rd.Next(0, CityMap.Lines.Keys.Count)];
//SelectedLine = CityMap.Lines[1];
} while (!SelectedLine.ToList().Exists(x => x == B.Name));
var Destinations = (from d in SelectedLine
where d != B.Name
select d).ToList();
string Destination = Destinations[rd.Next(0, Destinations.Count)];
if (!B.Passengers.Keys.ToList().Exists(x => x == Destination))
B.Passengers[Destination] = new ConcurrentQueue<Passenger>();
B.Passengers[Destination].Enqueue(new Passenger(this, B.Name, Destination));
}
}
yield return Self.Delay(Step); // random time
}
OutputResultHandler(
SimResult.BusstopRecords.ToDictionary(
kvp => kvp.Key,
kvp => kvp.Value),
SimResult.PassengerRecords.ToList(),
SimResult.TotalWaiting,
SimResult.TotalTravelling
);
// release
yield break;
}