Diagnostics and ExitException

6 posts, 1 answers
  1. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 24 Jan 2013 Link to this post

    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.
  2. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 25 Jan 2013 Link to this post

    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.
  3. DevCraft banner
  4. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 29 Jan 2013 Link to this post

    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
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 30 Jan 2013 Link to this post

    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.
  6. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 30 Jan 2013 Link to this post

    Hi Victor,

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

    Kind regards,
    Fabian
  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 30 Jan 2013 Link to this post

    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.
Back to Top
DevCraft banner