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 8296591

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:05:03+00:00 2026-06-08T15:05:03+00:00

So here is my problem with my Windows Phone application. I have Page 1

  • 0

So here is my problem with my Windows Phone application.

I have Page 1 that can navigate to Page 2. In Page 2 OnNavigateTo I make a async call.

This seems ok the first time I run the application, the async call creates a new worker thread and does work for me which is cool.
But I realize that if I go back to Page 1 and re-invoke Page 2 the problem appears: Now I have a new worker thread from the async call while the old one was not terminated. So there is a race between the two worker threads and cause a problem to my application.
I don’t have direct control to the threads since they are implicitly created by async methods.

So in this case, anyone has suggestion on how to deal with it or is there a common pattern of dealing with this issue?

  • 0 0 Answers
  • 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-06-08T15:05:04+00:00Added an answer on June 8, 2026 at 3:05 pm

    It depends on how you’re issuing the async request. If you’re using say, WebClient to do something like DownloadStringAsync you’ll see that your WebClient instance has a method CancelAsync that will set the cancelled property in your Completed event handler to true. Just call CancelAsync when you leave your page and test for this in your handler and you should be good.

    // in some button handler or whereever
    webClient.DownloadStringAsync("http://url.com")
    
    void OnLeavePage(object sender, EventArgs e) {
      webClient.CancelAsync();
    }
    
    void OnCompleted(object sender, DownloadStringCompletedEventArgs e) {
      if (e.Cancelled) {
        return;
      }
    
      // do your handling
    }
    

    If you don’t have CancelAsync you can pass in a UserState object that has a Cancelled property to emulate the behaviour (set it to true when you leave and test in your handler).

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

Sidebar

Related Questions

I am working on a Windows Phone application, here is the scenario that I
I'm battling a really weird problem here. I have a Windows 2008 R2 server
Here is my problem. If I use only one Windows Forms project and call
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I have a problem, I have written a simple Media Player for Windows Phone
We have a Service that continuously collects sensor data on the phone. This service
I have The following problem: I use facebook-c#-sdk for windows phone 7.1(mango version), taken
I have a windows phone app that allows the user to interact with it.
I'm trying to develop a Windows Phone 7 application. Part of this application includes
I am having problems debugging a Windows Phone XNA game application. I can build

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.