1
votes

I recently submitted a small app working on Silverlight framework. But my app got rejected from the marketplace due to error 5.2.3 i.e Application Responsiveness After Being Deactivated. What I found was : After a user successfully completes the game(a puzzle), I am showing him a dialog :

MessageBoxResult mr = MessageBox.Show("You have won! Do you want to start another game?", "Information", MessageBoxButton.OKCancel);
if(mr==MessageBoxResult.Cancel)
{
    NavigationService.GoBack();
}

Now the point is - If the user presses the start button after this dialog box is displayed, the app stops throwing an exception -
Navigation is not allowed when the task is not in the foreground. Error: -2147220990

It seems to me a valid error, though I am not sure how my other apps successfully passed the certification process though they had the same flaw. I have just started developing WP apps so I dont have much knowledge of things to do. Please could you help me a workaround.

1
check NavigationService.CanGoBack first. - William Melani
@willmel this will not work, when de-activated NavigationService.CanGoBack will still report true. - ColinE
@ColinE nevertheless, it should still be checked first. - William Melani

1 Answers

2
votes

It doesn't look like there is an easy test for this case. It would appear that the MessageBox is cancelled before the Deactivated event is fired, so there is no way that I can see to test for this state.

My suggestion would be to detect and swallow the specific exception:

  MessageBoxResult mr = MessageBox.Show("You have won! Do you want to start another game?", "Information", MessageBoxButton.OKCancel);
  if (mr == MessageBoxResult.Cancel)
  {
    try
    {
      NavigationService.GoBack();
    }
    catch (InvalidOperationException e)
    {
      // occurs if message box closed due to de-activation
    }
  }