如何在C#中与Web服务并行发出多个请求 [英] How to make Multiple requests in parallel to a webservice in C#
本文介绍了如何在C#中与Web服务并行发出多个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要按以下方式致电3个WCF服务
I need to call 3 WCF services as below,
var client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/json";
var resultJson1 = client.UploadString("http://localhost:45868/Product/GetAvailableProductsByContact",
jsonser1);
var resultJson2= client.UploadString("http://localhost:45868/Product/GetMemberProductsByContact",
jsonser2);
var resultJson3= client.UploadString("http://localhost:45868/Product/GetCoachProductsByContact",
jsonser3);
这需要大量时间才能获得结果并显示在页面上.谁能帮助我如何并行执行它们?
This takes a lot of time to get results and display on the page. Can anyone help me how I could execute them in parallel?
推荐答案
查看全文