public async Task <bool> NextTick() { Stopwatch t = new Stopwatch(); t.Start(); var tasks = new List <Task <bool> >(); foreach (var actor in vesselActors) { var grain = GrainFactory.GetGrain <IVessel>(actor); var r = grain.DoAction(OldTimeStamp, NewTimeStamp); tasks.Add(r); } var results = await Task.WhenAll(tasks.ToArray()); tasks = new List <Task <bool> >(); foreach (var actor in routeActors) { var grain = GrainFactory.GetGrain <IRoute>(actor); var r = grain.DoAction(OldTimeStamp, NewTimeStamp); tasks.Add(r); } results = await Task.WhenAll(tasks.ToArray()); tasks = new List <Task <bool> >(); foreach (var actor in portActors) { var grain = GrainFactory.GetGrain <IPort>(actor); var r = grain.DoAction(OldTimeStamp, NewTimeStamp); tasks.Add(r); } results = await Task.WhenAll(tasks.ToArray()); OldTimeStamp = OldTimeStamp.AddSeconds(Constants.TickSizeSeconds); NewTimeStamp = NewTimeStamp.AddSeconds(Constants.TickSizeSeconds); t.Stop(); using (StreamWriter w = File.AppendText("result.txt")) { w.WriteLine(t.ElapsedMilliseconds); } //logger.LogInformation("Tick time: " + t.Elapsed.ToString()); return(true); }
public Task <bool> IncreaseTimeStamps() { OldTimeStamp = OldTimeStamp.AddSeconds(Constants.TickSizeSeconds); NewTimeStamp = NewTimeStamp.AddSeconds(Constants.TickSizeSeconds); return(Task.FromResult(true)); }