This is a migrated thread and some comments may be shown as answers.

Diagnostics and ExitException

5 Answers 68 Views
Diagnostics
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
prog1
Top achievements
Rank 1
prog1 asked on 24 Jan 2013, 09:52 PM
I am using an ExitException within my application to quit it easy if the user has chosen this option.
Unfotunately I can not get it work with RadDiagnostics and I do not know why.

// Initialize
radDiagnostics = new RadDiagnostics();
            radDiagnostics.EmailTo = AppResources.SupportEmail;
            radDiagnostics.ApplicationName = AppResources.AppTitle;
            radDiagnostics.ApplicationVersion = AppResources.Version;
            radDiagnostics.EmailSubject = AppResources.AppTitle + " " + AppResources.Version + " " + AppResources.Error;
            radDiagnostics.HandleUnhandledException = true;
            radDiagnostics.Init();
            radDiagnostics.ExceptionOccurred += new EventHandler<ExceptionOccurredEventArgs>(RadDiagnostics_ExceptionOccurred);
 
// Handle
private void RadDiagnostics_ExceptionOccurred(object sender, ExceptionOccurredEventArgs e)
        {
            if (e.Exception is ExitException == true)
            {
                e.Cancel = true;
                e.Handled = false;
                return;
            }
            else
            {
                e.Handled = true;
            }
        }

The app will not be closed after ExitException has occured.

// By now
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is ExitException)
                return;
 
           // Handle error if it is not an ExitException
           // Create Mail for example
            e.Handled = true;
        }

This works well at the moment.

5 Answers, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 25 Jan 2013, 09:38 AM
Hi Fabian,

Thank you for contacting us.

First, I'd like to let you know that it is not recommended to exit a WP7 application, except when the user presses the BackKey when on the MainPage. However, if you still want to throw an exception to exit the application you can do this while handling your ExitException.
private void RadDiagnostics_ExceptionOccurred(object sender, ExceptionOccurredEventArgs e)
{
    if (e.Exception is ExitException)
    {
        throw new Exception();
    }
}

This way the exception will not be handled by RadDiagnostics and the application will quit.

I hope this information helps. Let me know if you have additional questions.

All the best,
Todor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
prog1
Top achievements
Rank 1
answered on 29 Jan 2013, 05:59 PM
Hi Todor,

thank you for the fast reply. Your solution is working.

I know that it is not recommended, but if you take a look at my app you will know why I need this.

Quick Alarm

Kind regards,
Fabian
0
Victor
Telerik team
answered on 30 Jan 2013, 09:42 AM
Hi Fabian,

Another way to termine your app is to call Application.Current.Terminate().

Kind regards,
Victor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
prog1
Top achievements
Rank 1
answered on 30 Jan 2013, 09:50 AM
Hi Victor,

thank you. Did not know that, yet.
But this is just for Windows Phone 8, isn't it?

Kind regards,
Fabian
0
Victor
Telerik team
answered on 30 Jan 2013, 09:56 AM
Hi Fabian,

Yes, this appears to only be available in WP8.

Kind regards,
Victor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Diagnostics
Asked by
prog1
Top achievements
Rank 1
Answers by
Todor
Telerik team
prog1
Top achievements
Rank 1
Victor
Telerik team
Share this question
or