Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3498328
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:28:39+00:00 2026-05-18T12:28:39+00:00

I’m trying to develop a Windows Phone 7 application. Part of this application includes

  • 0

I’m trying to develop a Windows Phone 7 application. Part of this application includes contacting an API to retrieve some data. To do so, I am utilizing HTTPWebRequest and a small helper class I’ve written; I call HTTPHelper’s sendAPIRequest and then retrieve the result.

The problem lies in the chain of execution following the initiation of the asynchronous request. Through my debugging, I’ve discovered that BeginGetRequestStream’s callback requestCallBack is called. This callback subsequently calls BeginGetResponse and its callback; unfortunately, its callback (responseCallBack) is never trigger. I’ve determined that the server the API is on is never contacted (there is nothing in Apache’s logs), and after execution of request.BeginGetResponse, the debugger shows an empty list of locals and an empty stack; the callback is never triggered, and the program goes nowhere. I’ve tried all types of debugging I can think of, but am at an end here. No exceptions are thrown, nothing looks off–the program just simply fails to contact the server and continue.

Here’s the code I’m using:

public class HTTPHelper
{
public string postString { get; set; }
public string responseData { get; set; }

    private static ManualResetEvent readyToGo = new ManualResetEvent(false);

    public void sendAPIRequest(string mode, string data)
    {
        GenericAPIRequest requestInformation = new GenericAPIRequest { data = data, device_id = getDeviceId(), method = mode };

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.1.69/api/master.php?source=client");
        request.ContentType = "application/x-www-form-urlencoded";
        request.Method = "POST";

        string postData = "device_id=" + getDeviceId() + "&data=" + JsonConvert.SerializeObject(requestInformation) + "&mode=" + mode;
        postString = postData;

        request.BeginGetRequestStream(new AsyncCallback(requestCallBack), request);

        // Stop the thread until we've finished our HTTP request
        readyToGo.WaitOne();
        return;
    }
    private void requestCallBack(IAsyncResult asynchronousResult)
    {
        HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;

        Stream postStream = request.EndGetRequestStream(asynchronousResult);

        byte[] postBytes = Encoding.UTF8.GetBytes(postString);

        postStream.Write(postBytes, 0, postString.Length);
        postStream.Close();

        request.BeginGetResponse(new AsyncCallback(responseCallBack), request);
        return;
    }
    private void responseCallBack(IAsyncResult asynchronousResult)
    {
        HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;

        HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
        Stream streamResponse = response.GetResponseStream();
        StreamReader streamRead = new StreamReader(streamResponse);

        responseData = streamRead.ReadToEnd();

        streamResponse.Close();
        streamRead.Close();
        response.Close();

        // Release the thread...
        readyToGo.Set();
        return;

    }
    private string getDeviceId()
    {
        // Gets the unique device ID, allows us to track the device.
        byte[] result = null;
        object uniqueId;

        if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
            result = (byte[])uniqueId;

        return System.BitConverter.ToString(result);
    }


Any suggestions as to what’s done wrong here?

Thanks for any and all suggestions you may have.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:28:39+00:00Added an answer on May 18, 2026 at 12:28 pm

    Try pulling out the readyToGo.WaitOne(). That will cause the thread to stop and wait for the signal. It’s likely that the request needs to process on that thread and so is not getting called.

    Oddly I had a very similar problem with reset events just a few minutes ago, though it was with WPF instead of HttpRequests :).

    BTW, I have a code reference library on CodePlex that includes an HttpWebRequest helper (it probably won’t directly help you here, just thought I would mention it). You are free to use it anyway you want (even just to take the parts of the code you like). The project is called BizArk and the class is called WebHelper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.