I'm working on an UWP MVVM project and would like to implement an automatic logout system if the user interaction stops for a specific time.
Until now I'm using a DispatcherTimer
to count backwards from 200 every second.
TimerLeave = 200;
var _dispatcherTimer = new DispatcherTimer();
_dispatcherTimer.Tick += dispatcherTimer_Tick;
_dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
_dispatcherTimer.Start();
But because the DispatcherTimer is linked
with the UI and I'm building a MVVM App, I'm looking for an alternative.
I searched a bit and found Run a background task on a timer. The problem is
that this timer can only be set to run every 15 minutes, which is a little too long to automaticly logout a user in my case. I found no workaround to reduce the 15 minutes.
So my question is, is there any possibility to set up a timer in an UWP Project that isn't linked to the UI and can be set variable?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…