silverlight - When does a PhoneApplicationPage get disposed? -


for example, if have page 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 app, navigate page, pop message box every 5 seconds. press "back" button on phone , navigate previous page. weird thing still pops message box every 5 seconds. know can stop timer in onnavigatedfrom method, why happening? isn't page disposed after press button on it?

thanks

it disposed gc when nothing keeping awake. dispatchertimer keeps awake, though created page. guess in past has been dispatchertimer being referenced dispatcher itself, , can't clean up, or along lines.

to demonstrate add finalize method

#if debug   ~mypage() {     system.diagnostics.debug.writeline("killing mypage");   } #endif 

then add button somewhere on main page force gc.collect()

if shut down timer in onnavigatedfrom page cleaned up, if not, not.

i haven't tested yet mango see if smarter, 7.0 tools had bit of work around this.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -