public override async Task Link() { List <IWorkerGrain> isolated = new List <IWorkerGrain>(); foreach (var pair in to.Layer) { if (!from.Layer.ContainsKey(pair.Key)) { isolated.AddRange(pair.Value); } } foreach (var pair in from.Layer) { ISendStrategy strategy = new RoundRobin(batchSize); if (to.Layer.ContainsKey(pair.Key)) { strategy.AddReceivers(to.Layer[pair.Key], true); strategy.AddReceivers(isolated); } else { strategy.AddReceivers(to.Layer.Values.SelectMany(x => x).ToList()); } foreach (IWorkerGrain grain in pair.Value) { await grain.SetSendStrategy(id, strategy); } } }