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 6187369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:02:47+00:00 2026-05-24T02:02:47+00:00

For example, if I have a page like this: public partial class Page1 :

  • 0

For example, if I have a page like this:

public partial class Page1 : PhoneApplicationPage
{
    DispatcherTimer timer = new DispatcherTimer();

    public Page1()
    {
        InitializeComponent();

        timer.Interval = TimeSpan.FromSeconds(5);
        timer.Tick += new EventHandler(timer_Tick);
        timer.Start();
    }

    void timer_Tick(object sender, EventArgs e)
    {
         MessageBox.Show("timer tick"); 
    }
}

In the app, I navigate to this page, it will pop up a message box every 5 seconds.
Then I press the “Back” button on the phone and navigate back to the previous page.
But the weird thing is that it still pops up a message box every 5 seconds.
I know I can stop the timer in the OnNavigatedFrom method, but why is this happening?
Isn’t a page disposed after you press the back button on it?

Thanks

  • 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-24T02:02:48+00:00Added an answer on May 24, 2026 at 2:02 am

    It will get disposed by the GC when nothing is keeping it awake. This DispatcherTimer keeps it awake, even though it was created by the page. My guess in the past has been that the DispatcherTimer is being referenced by the Dispatcher itself, and so can’t clean up, or something along those lines.

    To demonstrate add a finalize method

    #if DEBUG
      ~MyPage() {
        System.Diagnostics.Debug.WriteLine("Killing MyPage");
      }
    #endif
    

    Then add a button somewhere on the main page to force a GC.Collect()

    If you shut down the timer in OnNavigatedFrom your page will get cleaned up, if you do not, it will not.

    I haven’t tested this yet with Mango to see if it is smarter, but with the 7.0 tools I had to do a bit of work to get around this.

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

Sidebar

Related Questions

I have a page, URI looks like this: http://domain.example.com/Profiles/Profile.aspx?username=blah#blahtab When that fragment (#blahtab) is
I have a class that looks like this: public class TextField : TextBox {
I have two websites: http://example.com http://example.com/sub I have a page, let's say: http://example.com/sub/page1 Is
I have set of xml elements like this: <item code=<HTML_CODE> /> For example: <items>
I am trying to flatten nested objects like this: public class Book { public
Hi, I have a action that looks like this : [AcceptVerbs(HttpVerbs.Post)] public ActionResult Register(AdRegister
I am using ASP.NET partial views like in this example <% using (Html.BeginForm()) {
I used to have my permalinks to standard format, something like http://example.com/?page_id=2 . Now
If I for example have <p> some long text </p> on my HTML page,
I have a page which expects a numeric query string value. For example: Details.aspx?rgn=1234

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.