looking for solution, if i dont press any key or touch the screen for 2 minutes on windows-mobile - i need to return to LogIn screen
looking for solution, if i dont press any key or开发者_StackOverflow touch the screen for 2 minutes on windows-mobile
i need to return to LogIn screen (from any screen of my program).
thanks in advance
Run a timer which resets when you receive a OnTouch or OnKey Event and after a specified time return to to the Login Screen.
public partial class AnotherScreen : PhoneApplicationPage
{
private Timer _timer;
private int _timeSpan;
public AnotherScreen()
{
InitializeComponent();
_timer = new Timer(TimerTick,null,TimeSpan.Zero,TimeSpan.FromMinutes(2));
MouseEnter += (s, e) => _timeSpan = 0;
}
private void TimerTick(object obj)
{
_timeSpan += 1;
if (_timeSpan > 120)
{
Dispatcher.BeginInvoke(() =>NavigationService.Navigate(new Uri("/LoginScreen.xaml", UriKind.Relative)));
}
}
}
For Windows Mobile (i.e. not Windows Phone) take a look at this blog entry.
精彩评论