Hello,
Welcome to Microsoft Q&A!
I want my app can autosave the unsaved files over a period, for example 10s. How do I do that?
You could use aDispatcherTimer Class to achieve this.
Using DispatcherTimer Class;
DispatcherTimer dispatcherTimer;
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
DispatcherTimerSetup();
}
public void DispatcherTimerSetup()
{
dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += DispatcherTimer_Tick;
dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
dispatcherTimer.Start();
}
private void DispatcherTimer_Tick(object sender, object e)
{
//save the text
var text = MyTextBox.Text;
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.