Aborting the program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick De Ridder

    #1

    Aborting the program


    Given:

    I call Form2 from Form1.
    I throw an exception in Form2.
    A MessageBox ("Fatal error") is shown with an OK button.

    Question 1:

    I want to abort everything after pressing the OK button.
    How do I do this?

    Question 2:

    Alternatively, I want to return to Form1 after pressing the OK button.
    How do I do this?

    --
    Any suggestions?


    Many thanks,
    --
    Patrick De Ridder
    ngmail@freeler. nl

  • Joel Hendrix [MSFT]

    #2
    RE: Aborting the program

    I would wrap your invocation of Form2 in a try/catch block:

    try
    {
    Form2 theForm = new Form2();
    theForm.Show();
    }
    catch (Exception ex)
    {
    // handle exception here
    }
    --------------------[color=blue]
    >From: Patrick De Ridder <ngmail@freeler .nl>
    >Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    >Subject: Aborting the program
    >Date: Fri, 01 Aug 2003 13:38:09 +0200
    >Organization : Planet Internet
    >Lines: 26
    >Message-ID: <ipjkiv88uco2qf 787irjf3tn4230m 2holc@4ax.com>
    >NNTP-Posting-Host: ipc379b760.dial .hetnet.nl
    >Mime-Version: 1.0
    >Content-Type: text/plain; charset=us-ascii
    >Content-Transfer-Encoding: 7bit
    >X-Trace: reader11.wxs.nl 1059738074 21152 195.121.183.96 (1 Aug 2003[/color]
    11:41:14 GMT)[color=blue]
    >X-Complaints-To: abuse@planet.nl
    >NNTP-Posting-Date: 1 Aug 2003 11:41:14 GMT
    >X-Newsreader: Forte Agent 1.93/32.576 English (American)
    >Path:[/color]
    cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
    e.de!newsfeed.f reenet.de!eusc. inter.net!news. tele.dk!news.te le.dk!small.new s
    ..tele.dk!newsf eed.multikabel. nl!newsfeed.wxs .nl!textnews.wx s.nl!not-for-mail[color=blue]
    >Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1735 20
    >X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
    >
    >
    >Given:
    >
    >I call Form2 from Form1.
    >I throw an exception in Form2.
    >A MessageBox ("Fatal error") is shown with an OK button.
    >
    >Question 1:
    >
    >I want to abort everything after pressing the OK button.
    >How do I do this?
    >
    >Question 2:
    >
    >Alternativel y, I want to return to Form1 after pressing the OK button.
    >How do I do this?
    >
    >--
    >Any suggestions?
    >
    >
    >Many thanks,
    >--
    >Patrick De Ridder
    >ngmail@freeler .nl
    >
    >[/color]


    --

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm

    Note: For the benefit of the community-at-large, all responses to this
    message are best directed to the newsgroup/thread from which they
    originated.

    Comment

    • John Kennedy[MSFT]

      #3
      RE: Aborting the program

      And Application.Exi t() will abort EVERYTHING for you.

      Comment

      • Patrick De Ridder

        #4
        Re: Aborting the program

        On Wed, 06 Aug 2003 15:43:56 GMT, johnkenn@online .microsoft.com (John
        Kennedy[MSFT]) wrote:
        [color=blue]
        >And Application.Exi t() will abort EVERYTHING for you.[/color]
        Thank you,
        --
        Patrick De Ridder
        ngmail@freeler. nl

        Comment

        Working...