In App.xaml.cs
Timer IdleTimer = new Timer(new TimeSpan(00, 10, 00)); //HH,MM,SS
#region related to automatic logout after 30 mins
//Changes related to automatic logout after 30 mins
async void Idleimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (MainThread.IsMainThread)
GotoLogin();
else
MainThread.BeginInvokeOnMainThread(GotoLogin);
}
public void ResetIdleTimer()
{
IdleTimer.Stop();
IdleTimer.Start();
}
void GotoLogin()
{
// Code to run on the main thread
//this.Quit();
MainPage = new LoginPage();
}
#endregion
In MAUIProgram.cs
#region related to automatic logout after 30 mins
//Changes related to automatic logout after 30 mins
builder.ConfigureLifecycleEvents(events =>
{
#if WINDOWS
events
.AddWindows(windows => windows
.OnPlatformMessage((window, args) =>
{
if (args.MessageId == Convert.ToUInt32("0x0086", 16) ||
args.MessageId == Convert.ToUInt32("0x0020", 16) ||
args.MessageId == Convert.ToUInt32("0x0021", 16) )
{
(App.Current as App).ResetIdleTimer();
}
}));
#endif
});
#endregion
Need solution to close the popup as well?