I created a method, which gets data from Foursquare(for venues), and Google(for streets), based on a latitude,longitude address I provide. It is intended to show locations around you. The name of the results from the two apis are then put together in a list
It looks something like this:
var httpFoursquareResponse = (HttpWebResponse)httpFoursquareWebRequest.GetResponse();
var httpGoogleResponse = (HttpWebResponse)httpGoogleWebRequest.GetResponse();
List<string> foursquarePlacesNames=getNames(httpFoursquareResponse);
List<string> googleStreetsNames=getStreets(httpFoursquareResponse);
var result=foursquarePlacesNames.Union(googleStreetsNames);
return result;
Problem:
1) I want the requests to be sent at the same time(so I don’t have to wait for the first to get the second). But if I use AsyncCallbacks, how can I do that union, given the fact that I will have two responses handled by two different threads.
2) If more than 5 seconds pass and I have no response from one of the services, I want to return whatever data I have, and not care about the response anymore
How would you go about implementing something like this? I think it is a quite common scenario, but I didn’t find any solutions on the web.
Thank you
You can use Asyncmanager for this thing.
Please get thetwo link for this. This would help you.
1.http://www.devproconnections.com/article/aspnet2/calling-web-services-asynchronously
2.http://www.c-sharpcorner.com/UploadFile/rmcochran/multithreadasyncwebservice05262007094719AM/multithreadasyncwebservice.aspx