开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜