internal static async Task Main(string[] args) { const string localhost = "127.0.0.1"; var loggerFactory = new LoggerFactory(); loggerFactory.AddNLog(); LogManager.LoadConfiguration("nlog.config"); var store = new RocksDbKeyValueStore(); var memberList = new string[0]; Func <IEnumerable <string> > memberListProvider = () => memberList; var d1 = CreateDownloader(loggerFactory, @"R:\d1", store, memberListProvider); var d2 = CreateDownloader(NullLoggerFactory.Instance, @"R:\d2", store, memberListProvider); var s1 = new Server { Ports = { new ServerPort(localhost, ServerPort.PickUnused, ServerCredentials.Insecure) }, Services = { DownloaderService.BindService(d1.DownloaderService) } }; var s2 = new Server { Ports = { new ServerPort(localhost, ServerPort.PickUnused, ServerCredentials.Insecure) }, Services = { DownloaderService.BindService(d2.DownloaderService) } }; s1.Start(); s2.Start(); memberList = s1.Ports.Concat(s2.Ports).Select(p => $"{localhost}:{p.BoundPort}").ToArray(); var t1 = d1.InvokeAsync(); var t2 = d2.InvokeAsync(); await Task.WhenAll(t1, t2); await s1.ShutdownAsync(); await s2.ShutdownAsync(); Console.WriteLine("Finished"); }