在 mvvmcross v3 ViewModel
public class TimerViewModel : MvxViewModel
{
System.Timers.Timer timer;
public TimerViewModel()
{
timer = new System.Timers.Timer(500f);
timer.Elapsed += HandleTimerElapsed;
timer.Start();
}
void HandleTimerElapsed (object sender, ElapsedEventArgs e)
{
Debug.Log( "Time Elapsed" );
}
}
由于 MvxViewModel 没有实现 IDisposable,我应该把下面的代码放在哪里?
timer.Stop();
timer.Elapsed += HandleTimerElapsed;
我发现 mvvmcross 代码有一些 MvxWeakEventSubscription,它是用来解决我的问题的吗?