I just got tripped up by this in a Windows Store app, here is a simplified example:
App.cs: Global timer MainPage: Subscribes to Global Timer, button to create a local timer, button to goto page 2 Page2: Subscribes to Global Timer, button to create local timer, back button
On MainPage, it click the button to create a local timer. I see it and the global timer ticking.
Goto page 2. Still see ticks coming from subscribed global timer and local timer on Main Page. Start the local timer on page 2.
Go back, on MainPage. Now see 5 timers running:
The original MainPage subscribed to Global Timer the original MainPage subscribed to local timer A new subscription to Global Timer The Page2 subscribed to Global Timer The Page2 subscribed to it's local timer
I realize I can use the navigatedto/from events to subscribe/unsubscribe from the global timer. A bit of a pain because in my real example I can subscribe to dozens of different events in different pages from the global class. A little harder to find the timers created in the local timer button since there is no reference to it outside the button.
Are the subscribers keeping the previous pages alive or is this normal? I looked at NavigationCacheMode mode, by default creates a new instance each time. I assumed everything was basically cleared, which is why to have to save the state of textboxs, etc, when going between pages.
Is the only way around this to unsubscribe to all global events when navigating away, and to keep a class level variable so I have a reference to one off's like my "local timer"?