N
N
nicklayk2014-04-26 14:18:19
Windows phone
nicklayk, 2014-04-26 14:18:19

Refresh page Windows Phone?

There is a code, the essence is simple - we take information from the site, process it and give it to the user as a string in a TextBlock. I use HttpWebRequest HttpWebResponse, all is well.
The problem is this: I have the code in Page_Loaded, it is loaded 1 time. And if you change a line on the site and make a transition between pages in the application, nothing happens. The Application Bar has a refresh button with the following code:

private void ApplicationBarIconButton_Refresh(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml?" + DateTime.Now.Ticks, UriKind.Relative));
        }

But this does not help either, the page seems to be updated, but Request and Response do not start working again.
If you restart the application, everything is loaded on a new one and a new line is displayed.
I tried to put the code in GotFocus - nothing changed.
The question is - how will it be correct to implement refresh here?
Outputting to a separate function does not help. I sin on stream, here is the code:
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(@"site.com/.../.../");
    request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
}
public void ReadWebRequestCallback(IAsyncResult callbackResult)
{
   HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
   HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);

   StreamReader readStream = new StreamReader(myResponse.GetResponseStream());
   {
        string results = readStream.ReadToEnd();
         ///обработка и дальше вывод вывод
         Dispatcher.BeginInvoke(() => tbk_text.Text = Convert.ToString(str);
    }
    readStream.Close();
    myResponse.Close();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nicklayk, 2014-04-26
@nicklayk

The problem was that it constantly got into the cache.
Found the answer here: social.msdn.microsoft.com/forums/wpapps/en-US/3286...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question