Error and close application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rodrigo Juarez

    #1

    Error and close application

    Hi
    I'm using Visual Studio 2005 with visual basic, developing winforms
    applications
    I'm adding try catch blocks for error handling and I want to close the
    application when I got an error.
    Closing the form is not enough because there is a lot of forms open

    TIA

    Rodrigo Juarez


  • Armin Zingler

    #2
    Re: Error and close application

    "Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamschrieb
    Hi
    I'm using Visual Studio 2005 with visual basic, developing winforms
    applications
    I'm adding try catch blocks for error handling and I want to close
    the application when I got an error.
    Closing the form is not enough because there is a lot of forms open
    If you don't have multiple forms: Application.Exi tThread


    Armin

    Comment

    • Rodrigo Juarez

      #3
      Re: Error and close application

      Thanks for your reply
      I have a lot of forms open when I got error


      "Armin Zingler" <az.nospam@free net.deescribió en el mensaje
      news:eNEDSReUHH A.1200@TK2MSFTN GP02.phx.gbl...
      "Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamschrieb
      >Hi
      >I'm using Visual Studio 2005 with visual basic, developing winforms
      >applications
      >I'm adding try catch blocks for error handling and I want to close
      >the application when I got an error.
      >Closing the form is not enough because there is a lot of forms open
      >
      If you don't have multiple forms: Application.Exi tThread
      >
      >
      Armin

      Comment

      • Armin Zingler

        #4
        Re: Error and close application

        "Armin Zingler" <az.nospam@free net.deschrieb
        "Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamschrieb
        Hi
        I'm using Visual Studio 2005 with visual basic, developing
        winforms applications
        I'm adding try catch blocks for error handling and I want to close
        the application when I got an error.
        Closing the form is not enough because there is a lot of forms
        open
        >
        If you don't have multiple forms: Application.Exi tThread

        Correction:
        If you don't have multiple Threads...


        Armin

        Comment

        • RobinS

          #5
          Re: Error and close application


          "Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamwrote in message
          news:e5hVOJdUHH A.5060@TK2MSFTN GP06.phx.gbl...
          Hi
          I'm using Visual Studio 2005 with visual basic, developing winforms
          applications
          I'm adding try catch blocks for error handling and I want to close the
          application when I got an error.
          Closing the form is not enough because there is a lot of forms open
          >
          TIA
          >
          Rodrigo Juarez
          >
          So whenever you get an error, you want to close all of the forms and exit
          the application?

          Is that what you're trying to achieve?

          Robin S.
          Ts'i mahnu uterna ot twan ot geifur hingts uto.


          Comment

          • Rodrigo Juarez

            #6
            Re: Error and close application

            Yes, this is what I want

            Thanks!

            Rodrigo Juarez

            "RobinS" <RobinS@NoSpam. yah.noneescribi ó en el mensaje
            news:aeidnc-oU6MpaUjYnZ2dnU VZ_oipnZ2d@comc ast.com...
            >
            "Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamwrote in message
            news:e5hVOJdUHH A.5060@TK2MSFTN GP06.phx.gbl...
            >Hi
            >I'm using Visual Studio 2005 with visual basic, developing winforms
            >applications
            >I'm adding try catch blocks for error handling and I want to close the
            >application when I got an error.
            >Closing the form is not enough because there is a lot of forms open
            >>
            >TIA
            >>
            >Rodrigo Juarez
            >>
            >
            So whenever you get an error, you want to close all of the forms and exit
            the application?
            >
            Is that what you're trying to achieve?
            >
            Robin S.
            Ts'i mahnu uterna ot twan ot geifur hingts uto.
            >
            >

            Comment

            • RobinS

              #7
              Re: Error and close application

              If you are catching the exceptions in your code, you can choose whether to
              throw them up another level or handle them. Generally, it's best to handle
              them "in place". Why would you want to shut everything down just because
              there is an error?

              At any rate, if you want to do this, you have to figure out where you want
              to close your forms. If you do it in a Form_Closing event, you'll need to
              close all *other* forms. If you try to close a form in its own Form_Closing
              event, it will probably loop infinitely or something.

              For Each myForm As Form In My.Application. OpenForms
              If myForm.name <"whateverformi scallingthis" Then
              myForm.Close()
              End If
              Next

              If you are letting the exceptions bubble up to the top and handling them in
              the Application UnhandledExcept ion event that I told you about in the other
              thread, you can just close all the forms there.

              For Each myForm As Form In My.Application. OpenForms
              myForm.Close()
              Next

              IMHO, this is not a best practice. <:-O

              Robin S.
              -----------------------------------------
              "Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamwrote in message
              news:e9LiN4fUHH A.868@TK2MSFTNG P05.phx.gbl...
              Yes, this is what I want
              >
              Thanks!
              >
              Rodrigo Juarez
              >
              "RobinS" <RobinS@NoSpam. yah.noneescribi ó en el mensaje
              news:aeidnc-oU6MpaUjYnZ2dnU VZ_oipnZ2d@comc ast.com...
              >>
              >"Rodrigo Juarez" <tiempotecnolog ia@newsgroup.no spamwrote in message
              >news:e5hVOJdUH HA.5060@TK2MSFT NGP06.phx.gbl.. .
              >>Hi
              >>I'm using Visual Studio 2005 with visual basic, developing winforms
              >>application s
              >>I'm adding try catch blocks for error handling and I want to close the
              >>application when I got an error.
              >>Closing the form is not enough because there is a lot of forms open
              >>>
              >>TIA
              >>>
              >>Rodrigo Juarez
              >>>
              >>
              >So whenever you get an error, you want to close all of the forms and
              >exit the application?
              >>
              >Is that what you're trying to achieve?
              >>
              >Robin S.
              >Ts'i mahnu uterna ot twan ot geifur hingts uto.
              >>
              >>
              >
              >

              Comment

              • Jeffrey Tan[MSFT]

                #8
                Re: Error and close application

                Hi Robin ,

                Thank you for sharing your idea with Rodrigo!

                I agree with most of your comment. Based on my experience, there are 2
                types of exceptions/errors in application, one is expected and one is
                unexpected. Expected error(such as file not found etc..) is known to the
                developers, so it would be safe to gracefully recover from this error and
                let the application continue to run without closing. In the unexpected
                error scenario, I think it may be better to close the application, since
                developers know nothing of this error, it may be hardware error, memory
                insufficiency or even memory corruption, so it may be unsafe to run from
                this situation. The recommended solution in this scenario may be closing
                the entire application. Also, this is default behavior of Win32 unhandled
                exception filter in NTDLL.

                Additionally, Rodrigo, you may also use Application.Exi t() method to close
                the entire applicatin if you think it is suitable. This will correctly
                inform all message pumps that they must terminate, and then close all
                application windows after the messages have been processed based on the
                MSDN. So I assume this method may meet your need.

                Thanks.

                Best regards,
                Jeffrey Tan
                Microsoft Online Community Support
                =============== =============== =============== =====
                Get notification to my posts through email? Please refer to
                http://msdn.microsoft.com/subscripti...ult.aspx#notif
                ications.

                Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
                where an initial response from the community or a Microsoft Support
                Engineer within 1 business day is acceptable. Please note that each follow
                up response may take approximately 2 business days as the support
                professional working with you may need further investigation to reach the
                most efficient resolution. The offering is not appropriate for situations
                that require urgent, real-time or phone-based interactions or complex
                project analysis and dump analysis issues. Issues of this nature are best
                handled working with a dedicated Microsoft Support Engineer by contacting
                Microsoft Customer Support Services (CSS) at
                http://msdn.microsoft.com/subscripti...t/default.aspx.
                =============== =============== =============== =====
                This posting is provided "AS IS" with no warranties, and confers no rights.

                Comment

                • Jeffrey Tan[MSFT]

                  #9
                  Re: Error and close application

                  Hi Rodrigo,

                  Have you reviewed all the replies to you? Do they make sense to you? If you
                  still need any help or have any concern, please feel free to feedback,
                  thanks.

                  Best regards,
                  Jeffrey Tan
                  Microsoft Online Community Support
                  =============== =============== =============== =====
                  Get notification to my posts through email? Please refer to
                  http://msdn.microsoft.com/subscripti...ult.aspx#notif
                  ications.

                  Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
                  where an initial response from the community or a Microsoft Support
                  Engineer within 1 business day is acceptable. Please note that each follow
                  up response may take approximately 2 business days as the support
                  professional working with you may need further investigation to reach the
                  most efficient resolution. The offering is not appropriate for situations
                  that require urgent, real-time or phone-based interactions or complex
                  project analysis and dump analysis issues. Issues of this nature are best
                  handled working with a dedicated Microsoft Support Engineer by contacting
                  Microsoft Customer Support Services (CSS) at
                  http://msdn.microsoft.com/subscripti...t/default.aspx.
                  =============== =============== =============== =====
                  This posting is provided "AS IS" with no warranties, and confers no rights.

                  Comment

                  Working...