private void Dispatch(Tuple <Uri, T> nodeAndWorkItemPair) { var cf = new ChannelFactory <IGridNode <T> >(new NetTcpBinding(), new EndpointAddress(nodeAndWorkItemPair.Item1)); IGridNode <T> proxy = cf.CreateChannel(); proxy.InvokeAsync(nodeAndWorkItemPair.Item2) .ContinueWith(t => { ((IClientChannel)proxy).Close(); nodes.Post(nodeAndWorkItemPair.Item1); }); }
public GridDispatcher(IGridNode <T> localService) { var localDispacther = new ActionBlock <T>(wi => { Console.WriteLine("Executing locally"); return(localService.InvokeAsync(wi)); }, new ExecutionDataflowBlockOptions { BoundedCapacity = 2, MaxDegreeOfParallelism = 2 }); var dispatcher = new ActionBlock <Tuple <Uri, T> >((Action <Tuple <Uri, T> >)Dispatch); _workItems.LinkTo(localDispacther); _workItems.LinkTo(_scheduler.Target2); _nodes.LinkTo(_scheduler.Target1); _scheduler.LinkTo(dispatcher); }