static void Main(string[] args) { ThirdParty_Service thirdPartyService = new ThirdParty_Service(); YourService yourService = new YourService(thirdPartyService); Parallel.For(1, 10, async i => { MenuData menu = await yourService.GetMenuData(i.ToString()); Console.WriteLine($"MenuId: {menu.MenuId}, Name: {menu.Name}"); Console.WriteLine("======================================"); }); //Parallel.For(1, 5, async i => //{ // IEnumerable<CategoryData> categories = await yourService.GetCategories(i.ToString()); // foreach (CategoryData item in categories) // { // Console.WriteLine($"MenuId: {item.MenuId}, Name: {item.Name}"); // } // Console.WriteLine("======================================"); //}); Console.WriteLine("Hello World."); Console.ReadKey(); }
public YourService(ThirdParty_Service thirdPartyService) { _thirdPartyService = thirdPartyService; }