Sweta Sinha

Sweta Sinha

  • NA
  • 51
  • 42.1k

Synchronous HttpWebRequest in Wp8

Dec 11 2014 2:50 AM
As I have gone through the examples,I have come across only asynchronous http web request having callback methods,like:-
private void getList(string restApiPath, Dictionary<string, string> output, Type type, string label)     {          webRequest = (HttpWebRequest)WebRequest.Create(restApiPath);         path = restApiPath;         labelValue = label;         webRequest.Method = "POST";          webRequest.ContentType = Globals.POST_CONTENT_TYPE;         webRequest.Headers["st"] = MPFPConstants.serviceType;          webRequest.BeginGetRequestStream(result =>         {             HttpWebRequest request = (HttpWebRequest)result.AsyncState;             // End the stream request operation             Stream postStream = request.EndGetRequestStream(result);              // Create the post data             string reqData = Utils.getStringFromList(output);               string encode = RESTApi.encodeForTokenRequest(reqData);              byte[] byteArray = Encoding.UTF8.GetBytes(encode);              postStream.Write(byteArray, 0, byteArray.Length);             postStream.Close();               request.BeginGetResponse(new AsyncCallback(GetResponseCallbackForSpecificConditions), request);          }, webRequest);     }      private void GetResponseCallbackForSpecificConditions(IAsyncResult ar)     {       //code      }
Kindly Suggest me if we can make a synchronous httpwebrequest for wp8?

Answers (1)