Application.Exit() did not exist the application.

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

    Application.Exit() did not exist the application.

    Hi,
    I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle user
    click close button .

    Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles btnclose.Click
    Me.Close()
    System.Windows. Forms.Applicati on.Exit
    End Sub

    However, the application continues to run when user click close, thought the
    form did close.

    Is there anything I miss out?

    Thanks.


  • Cablewizard

    #2
    Re: Application.Exi t() did not exist the application.

    ah, good ol logic error.
    Me.Close() did what it was supposed to. Closed the form and stopped execution
    of the form along with it's resources.
    The Application.Exi t command never got processed.
    You could just remove the Me.Close().
    If you want to make the form go away but continue to run, you might try
    Me.Hide().
    Then the Application.Exi t command should execute.
    Although if your code was still running, this might not be the most graceful way
    or appropriate place to exit.

    Gerald

    "Shelby" <shelby@itsuppo rt.com.sg> wrote in message
    news:uymGYnlXEH A.1652@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi,
    > I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle user
    > click close button .
    >
    > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
    > System.EventArg s) Handles btnclose.Click
    > Me.Close()
    > System.Windows. Forms.Applicati on.Exit
    > End Sub
    >
    > However, the application continues to run when user click close, thought the
    > form did close.
    >
    > Is there anything I miss out?
    >
    > Thanks.
    >
    >[/color]


    Comment

    • Shelby

      #3
      Re: Application.Exi t() did not exist the application.

      Hi,
      I have change to
      Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
      System.EventArg s) Handles btnclose.Click
      System.Windows. Forms.Applicati on.Exit
      End Sub

      The application is still running and the form also close without the
      me.close() statement.



      "Cablewizar d" <Cablewizard@Ya hoo.com> wrote in message
      news:OsaRB%23lX EHA.3664@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      > ah, good ol logic error.
      > Me.Close() did what it was supposed to. Closed the form and stopped[/color]
      execution[color=blue]
      > of the form along with it's resources.
      > The Application.Exi t command never got processed.
      > You could just remove the Me.Close().
      > If you want to make the form go away but continue to run, you might try
      > Me.Hide().
      > Then the Application.Exi t command should execute.
      > Although if your code was still running, this might not be the most[/color]
      graceful way[color=blue]
      > or appropriate place to exit.
      >
      > Gerald
      >
      > "Shelby" <shelby@itsuppo rt.com.sg> wrote in message
      > news:uymGYnlXEH A.1652@TK2MSFTN GP09.phx.gbl...[color=green]
      > > Hi,
      > > I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle[/color][/color]
      user[color=blue][color=green]
      > > click close button .
      > >
      > > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
      > > System.EventArg s) Handles btnclose.Click
      > > Me.Close()
      > > System.Windows. Forms.Applicati on.Exit
      > > End Sub
      > >
      > > However, the application continues to run when user click close, thought[/color][/color]
      the[color=blue][color=green]
      > > form did close.
      > >
      > > Is there anything I miss out?
      > >
      > > Thanks.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Manuel Canas

        #4
        Re: Application.Exi t() did not exist the application.

        Just put a simple End in the Sub
        [color=blue]
        > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
        > System.EventArg s) Handles btnclose.Click[/color]

        End
        [color=blue]
        > End Sub[/color]

        This Should do it.

        Manny


        "Shelby" <shelby@itsuppo rt.com.sg> wrote in message
        news:uymGYnlXEH A.1652@TK2MSFTN GP09.phx.gbl...[color=blue]
        > Hi,
        > I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle[/color]
        user[color=blue]
        > click close button .
        >
        > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
        > System.EventArg s) Handles btnclose.Click
        > Me.Close()
        > System.Windows. Forms.Applicati on.Exit
        > End Sub
        >
        > However, the application continues to run when user click close, thought[/color]
        the[color=blue]
        > form did close.
        >
        > Is there anything I miss out?
        >
        > Thanks.
        >
        >[/color]


        Comment

        • Shelby

          #5
          Re: Application.Exi t() did not exist the application.

          Thank you...



          "Manuel Canas" <mcanasc@hotmai l.com> wrote in message
          news:YzsEc.3894 0$_5.11257@clgr ps13...[color=blue]
          > Just put a simple End in the Sub
          >[color=green]
          > > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
          > > System.EventArg s) Handles btnclose.Click[/color]
          >
          > End
          >[color=green]
          > > End Sub[/color]
          >
          > This Should do it.
          >
          > Manny
          >
          >
          > "Shelby" <shelby@itsuppo rt.com.sg> wrote in message
          > news:uymGYnlXEH A.1652@TK2MSFTN GP09.phx.gbl...[color=green]
          > > Hi,
          > > I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle[/color]
          > user[color=green]
          > > click close button .
          > >
          > > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
          > > System.EventArg s) Handles btnclose.Click
          > > Me.Close()
          > > System.Windows. Forms.Applicati on.Exit
          > > End Sub
          > >
          > > However, the application continues to run when user click close, thought[/color]
          > the[color=green]
          > > form did close.
          > >
          > > Is there anything I miss out?
          > >
          > > Thanks.
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Cor Ligthert

            #6
            Re: Application.Exi t() did not exist the application.

            Hi Shelby,

            Using that *end* statement is worse than setting the power of from your
            computer.

            When the me.close is on the main form, that is normaly enough, you do not
            need that application.exi t

            However when it is not on the mainclass, you have normally to close in the
            class where you started the application.

            I hope this helps?

            Cor


            Comment

            • Andy Becker

              #7
              Re: Application.Exi t() did not exist the application.


              "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
              news:O0XiZ2mXEH A.3016@tk2msftn gp13.phx.gbl...[color=blue]
              > Hi Shelby,
              >
              > Using that *end* statement is worse than setting the power of from your
              > computer.[/color]

              I am interesting in knowing why you think this?

              Best Regards,
              Andy


              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: Application.Exi t() did not exist the application.

                * "Andy Becker" <x@x.com> scripsit:[color=blue][color=green]
                >> Using that *end* statement is worse than setting the power of from your
                >> computer.[/color]
                >
                > I am interesting in knowing why you think this?[/color]

                <msdn>
                The End statement can be placed anywhere in a procedure to end code
                execution, close files opened with an Open statement, and clear
                variables. The End statement calls the Exit method of the Environment
                class in the System namespace. System.Environm ent.Exit requires that you
                have SecurityPermiss ionFlag.Unmanag edCode permissions. If you do not, a
                SecurityExcepti on error occurs.

                When executed, the End statement clears all variables at module and
                class level and all static local variables in all modules.

                Note The End statement stops code execution abruptly, without invoking
                the Finalize method or any other Visual Basic code. Object references
                held by other programs are invalidated.

                The End statement provides a way to force your program to halt. Your
                program closes as soon as there are no other programs holding references
                to its objects and none of its code is executing.

                If your application has any forms open, you should close them before
                executing End. A console application can either use End or simply return
                from the Main procedure.
                </msdn>

                --
                Herfried K. Wagner [MVP]
                <URL:http://dotnet.mvps.org/>

                Comment

                • Cor Ligthert

                  #9
                  Re: Application.Exi t() did not exist the application.

                  > > Hi Shelby,[color=blue][color=green]
                  > >
                  > > Using that *end* statement is worse than setting the power of from your
                  > > computer.[/color]
                  >
                  > I am interesting in knowing why you think this?[/color]

                  Because it stops direct the program and does not free any resources anymore.
                  (It kills the process). When you power off than the resources are directly
                  freeed when you put the power on again.


                  Cor


                  Comment

                  • Jeff Johnson [MVP: VB]

                    #10
                    Re: Application.Exi t() did not exist the application.


                    "Manuel Canas" <mcanasc@hotmai l.com> wrote in message
                    news:YzsEc.3894 0$_5.11257@clgr ps13...
                    [color=blue]
                    > Just put a simple End in the Sub
                    >[color=green]
                    > > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
                    > > System.EventArg s) Handles btnclose.Click[/color]
                    >
                    > End[/color]

                    Oh man, that thing still exists in .NET?

                    And what's even worse is that people STILL suggest it!!


                    Comment

                    • Cablewizard

                      #11
                      Re: Application.Exi t() did not exist the application.

                      > The application is still running and the form also close without the[color=blue]
                      > me.close() statement.
                      >[/color]

                      The above statement leads me to believe that there are other things going on we
                      need to account for.
                      It sounds as if we need a little more information about the structure of your
                      program.
                      Is this a Form based app? Single or multi-threaded? Do you know?
                      What created the form? Is it your default form that starts up, or did you spawn
                      it from someplace else, such as as module or class?
                      [color=blue]
                      > I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle user
                      > click close button .[/color]
                      Now this is interesting. Can you give us a sample of what you are doing and why?
                      Am I really to read this as something like:

                      Do
                      System.Windows. Forms.Applicati on.DoEvents()
                      Loop

                      I can't imagine a scenario where that alone would be a good thing.
                      Give us a little more info so we can point you in the right direction.

                      Gerald


                      Comment

                      • Andy Becker

                        #12
                        Re: Application.Exi t() did not exist the application.

                        Ouch. Somewhere in the back of my mind, I was hoping that VB.NET would have
                        done something more graceful.

                        And I'm sure that somewhere, in the back of everyone else's mind who is
                        reading this, they were hoping I would RTFM before posting trash. :-)

                        Best Regards,
                        Andy


                        Comment

                        • Manuel Canas

                          #13
                          Re: Application.Exi t() did not exist the application.

                          Well people I suggested it because freaking MICROSOFT is putting that *end*
                          statement on their sample applications!!!
                          sorry about that.

                          Manny.

                          "Shelby" <shelby@itsuppo rt.com.sg> wrote in message
                          news:uymGYnlXEH A.1652@TK2MSFTN GP09.phx.gbl...[color=blue]
                          > Hi,
                          > I used System.Windows. Forms.Applicati on.DoEvents() in a loop to handle[/color]
                          user[color=blue]
                          > click close button .
                          >
                          > Private Sub btnclose_Click( ByVal sender As System.Object, ByVal e As
                          > System.EventArg s) Handles btnclose.Click
                          > Me.Close()
                          > System.Windows. Forms.Applicati on.Exit
                          > End Sub
                          >
                          > However, the application continues to run when user click close, thought[/color]
                          the[color=blue]
                          > form did close.
                          >
                          > Is there anything I miss out?
                          >
                          > Thanks.
                          >
                          >[/color]


                          Comment

                          • Cor Ligthert

                            #14
                            Re: Application.Exi t() did not exist the application.

                            Hi Manuel,
                            [color=blue]
                            > Well people I suggested it because freaking MICROSOFT is putting that[/color]
                            *end*[color=blue]
                            > statement on their sample applications!!!
                            > sorry about that.[/color]

                            I thought that I has seen that also once. I thought it was a sample with
                            more errors (some C code in it as wel)l, can it be the same?

                            And do not look at the message from non a regulars in this newsgroup, who
                            send messages in a kind of flaming way. They regulars of this newsgroup are
                            helping you when that goes to far you know.

                            So go on in the way you was starting with.

                            :-)

                            Cor


                            Comment

                            • Shelby

                              #15
                              Re: Application.Exi t() did not exist the application.

                              Hi Cor,

                              this project is a COM Addin for Outlook.
                              Currently for the testing purposes, I have set it as a Console Application,
                              and set the StartUp to a particular Form.

                              In both case, are they in the mainclass?
                              What do you mean by have to close in the class where I start the
                              application?

                              Shelby


                              "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
                              news:O0XiZ2mXEH A.3016@tk2msftn gp13.phx.gbl...[color=blue]
                              > Hi Shelby,
                              >
                              > Using that *end* statement is worse than setting the power of from your
                              > computer.
                              >
                              > When the me.close is on the main form, that is normaly enough, you do not
                              > need that application.exi t
                              >
                              > However when it is not on the mainclass, you have normally to close in the
                              > class where you started the application.
                              >
                              > I hope this helps?
                              >
                              > Cor
                              >
                              >[/color]


                              Comment

                              Working...