I have a checkbox. On it’s checked event I want to turn off IdleDetectionMode and on unchecked event I want to turn on. This is the code :-
private void chkRunInBackground_Checked(object sender, RoutedEventArgs e)
{
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
}
private void chkRunInBackground_Unchecked(object sender, RoutedEventArgs e)
{
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;
}
The checked event runs fine but on unchecked event I get, IdleDetection mode cannot be started once it is disabled. Why is this restriction applied and what can I do to work around it?
From MSDN:
The following code snippet shows an implementation of this.