Silverlight – iDLEDEtectionMode Error Windows Phone 7

I have a checkbox. In its check event I want to turn off IdleDetectionMode and 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;

}

Already The checked events are running normally, but in the unacquired events, the IdleDetection mode cannot be started after being disabled. Why do I need to apply this restriction, and what can I do to resolve it?

From MSDN:

In the current release, application
idle detection cannot be enabled in a
single application instance once it
has been disabled. Doing so throws an
exception. In future releases this may< br> be supported, so your application may
choose to disable application idle
detection when it is no longer needed
and catch the expected exception.

The following code snippet This implementation is shown.

// Custom function to turn off idle detection. This will throw an exception in the current release.
public void TryReenableApplicationIdleDetection()
{
bool didEnable = false;
try
{
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode =
Microsoft.Phone.Shell.IdleDetectionMode. Enabled;
didEnable = true;
}
catch (InvalidOperationExcepti on ex)
{
// This exception is expected in the current release.
}

// possibly use the value of didEnable to decide what to do next
// if it is'true' then your app will be deactivated
// if it is'false' then your app will keep running
}

< /p>

I have a checkbox. In its check event I want to turn off IdleDetectionMode and 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 is running normally , But in unacquired events, IdleDetection mode cannot be started after being disabled. Why should this restriction be applied and what should I do to resolve it?

From MSDN:

In the current release, application
idle detection cannot be enabled in a
single application instance once it
has been disabled. Doing so throws an
exception. In future releases this may
be supported, so your application may
choose to disable application idle
detection when it is no longer needed
and catch the expected exception.

The following code snippet shows this implementation.

// Custom function to turn off idle detection. This will throw an exception in the current release.
public void TryReenableApplicationIdleDetection()
{
bool didEnable = false;
try
{
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode =
Microsoft.Phone.Shell.IdleDetectionMode.Enabled;
didEnable = true;
}
catch (InvalidOperationException ex)
{
// This exception is expecte d in the current release.
}

// possibly use the value of didEnable to decide what to do next
// if it is'true' then your app will be deactivated
// if it is'false' then your app will keep running
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4022 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.