【发布时间】:2011-07-20 21:24:31
【问题描述】:
例如,如果我有这样的页面:
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");
}
}
在应用程序中,我导航到此页面,它会每 5 秒弹出一个消息框。 然后我按下手机上的“返回”按钮并导航回上一页。 但奇怪的是,它仍然每 5 秒弹出一个消息框。 我知道我可以在 OnNavigatedFrom 方法中停止计时器,但为什么会这样呢? 页面不是按后退键就被释放了吗?
谢谢
【问题讨论】:
-
遇到了同样的问题,不明白为什么
-
+1:正如我们在调查这个问题时发现的那样:stackoverflow.com/questions/6762606/… 当您离开页面时,页面不会被处理掉。
标签: silverlight windows-phone-7 navigation dispose