Hi @Ronald Rex ,
What's your operating system? If you have win7 operating system,the Windows 7 operating system comes with application recovery and restart (ARR), which allows you to save the data you are currently working on while your application is unresponsive or even crashing, and recover the application and previous data.We'll do this with the Windows API Code Pack.First, let's create a simple WPF program. Registration of ARR is required when the application loads, and ARR is also required to log off when the application is closed.
<Window x:Class="AppRestartRecovery.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="crashBtn" Content="Application Crash"
Margin="169,104,172,168" Click="crashBtn_Click"/>
<Button x:Name="closeBtn" Content="Close Application"
Margin="169,189,172,83" Click="closeBtn_Click"/>
</Grid>
</Window> Register for ARpublic MainWindow()
{
InitializeComponent();
RegisterForRestartRecovery();
... ...
} Log off the ARprivate void closeBtn_Click(object sender, RoutedEventArgs e)
{
UnRegisterRestartRecovery();
App.Current.Shutdown();
}
Add Microsoft.WindowsAPICodePack .dll to your project, and add Microsoft.Windows APICodePack.ApplicationServices; The namespace. Next we'll start writing the RegiserForRestart Recovery and UnRegiste
If the answer is helpful, please click "Accept Answer" and upvote it.
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.
Best regards,
Yijing Sun