Apoorv
Apoorv

Reputation: 2043

Message Box Crashes after 10 seconds in Windows Phone 7 App

This is a problem i am experiencing in WP 7 app dev. Actually I want to detect the presence of network while the application launches I use this code

bool isNetwork=NetworkInterface.GetIsNetworkAvailable();
if(!isnetwork) 
{    
    MessageBox.Show("No Network Available","App Name",MessageBoxButton.OkCancel); 
}

The following code i am writing in the Constructor() of the class , I just want to know two things

  1. Where should I write the code so that when the application opens, the message box is displayed and until the user selects "yes" or "No" the messagebox remains intact.
  2. I want to exit the application when the user presses the "NO " button on the MessageBox

    I was confused, should i use the application_launching() event or Should I code in OnNavigatedTo() ?

Proper code is required ! Thanks :-)

Upvotes: 1

Views: 449

Answers (1)

nkchandra
nkchandra

Reputation: 5557

If you write your MessageBox in Constructor on OnNavigatedTo events, you will face the same issue. You have to handle it wisely in the page's Loaded event handler.

Programmatically there is no preffered way to exit the app. Instead of deciding to exit the app, I suggest you show some static content and a "No network available, try later" text on the page.

Upvotes: 2

Related Questions