0
我的代碼啓動DispatcherTimer。檢測用戶活動windows phone 8
我只需要檢測任何種類的用戶聯繫,以重新啓動DispatcherTimer?
public partial class MainMenu : PhoneApplicationPage
{
public MainMenu()
{
InitializeComponent();
startTimer();
}
private DispatcherTimer dispatcherTimer;
private void startTimer()
{
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Start();
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
dispatcherTimer.Stop();
AllMyFunctions.logout_code(this);
}
private void restartTimer()
{
dispatcherTimer.Stop();
startTimer();
}
}
如何檢測任何種類的用戶交互以便觸發restartTimer()方法?