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?
You can use the task parallelism library:
Or alternatively, since your requests are all very similar, differing only by the url and upload string, you can use LINQ
AsParallelarray processing: