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

  • SEARCH
  • Home
  • 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 7022081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:32:03+00:00 2026-05-27T23:32:03+00:00

PageA Navigated to PageB There is a thread is running for HttpWebRequest. Back Key

  • 0

PageA Navigated to PageB
There is a thread is running for HttpWebRequest.
Back Key is invalid when the Thread is running.
PageB Code:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        Debug.WriteLine("OnNavigatedTo");
        //base.OnNavigatedTo(e);
        DoWork();
    }

void DoWork()
    {
        t = new Thread(new ThreadStart(() =>
        {
            request = WebRequest.Create("http://www.google.com") as HttpWebRequest;
            request.BeginGetResponse(new AsyncCallback(AsyncBack), request);
        }));
        t.IsBackground = true;
        t.Start();
    }


void AsyncBack(IAsyncResult ias)
    {
        HttpWebRequest req = (HttpWebRequest)ias.AsyncState;
        using (HttpWebResponse res = req.EndGetResponse(ias) as HttpWebResponse)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                this.PageTitle.Text = res.ContentLength.ToString();
                long length = res.ContentLength;
                for (long i = 0; i < length; i++)
                {
                    //here imitate a long time for working
                    Debug.WriteLine(i);
                    if (i == length)
                    {
                        break;
                    }
                }
                Debug.WriteLine(res.ContentLength);
            });
        }
    }

the Back Key is invalid until Method AsyncBack() is done.
‘Back Key is invalid’ Is that the app is not back to PageA when you touch the Back Key until Method AsyncBack() Done.
Why? Help me?

  • 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-27T23:32:04+00:00Added an answer on May 27, 2026 at 11:32 pm

    Why the bloody hell are you wrapping a async request in a custom thread? That doesn’t even remotely make sense.

    Then again, your question doesn’t make much sense either, but most likely the error is related to the request is attempting to invoke a operation, via. the dispatcher, on the wrong page.

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

Sidebar

Related Questions

I have the following code to detect user navigation or close. The post back
My silverlight application has 2 pages, PageA and PageB. Each page is binding to
is there a way to navigate two pages back in Windows Phone 7? I
I have a Page in Silverlight which is Navigated from the MainPage.xaml, called OpenPage.xaml,
I have a user on what we will call PageA.aspx. This user needs to
I've run into a situation with loading content from an xml file. Basically there
When you refresh/reload a page or use the back button, Firefox is kind enough
Is there any way to prevent a click from an <a> triggering delegated click
When I get referrer url, IIS 7 throws an exception. My code like this:
There are many tools that scrape HTML pages with javascript off, however are there

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.