Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Quit Console Application

How to Quit Console Application

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harkamal Singh
    wrote on last edited by
    #1

    I have a console application spanning multiple methods and functions, and based on a flag value I wish to abort program execution. Is there any other method other than break(which cannot be used always)? Thanks! h.

    B N L V 4 Replies Last reply
    0
    • H Harkamal Singh

      I have a console application spanning multiple methods and functions, and based on a flag value I wish to abort program execution. Is there any other method other than break(which cannot be used always)? Thanks! h.

      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #2

      You basically want something like this, I can't help more without knowing more.

          static bool abort;
          static void Main(string\[\] args)
          {
              while (!abort)
              {
                  DoStuff();
              }
          }
      
      1 Reply Last reply
      0
      • H Harkamal Singh

        I have a console application spanning multiple methods and functions, and based on a flag value I wish to abort program execution. Is there any other method other than break(which cannot be used always)? Thanks! h.

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Environment.Exit() not working for you?

        1 Reply Last reply
        0
        • H Harkamal Singh

          I have a console application spanning multiple methods and functions, and based on a flag value I wish to abort program execution. Is there any other method other than break(which cannot be used always)? Thanks! h.

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Have you tried Environment.Exit() ? It worked for me


          My Website | Ask smart questions

          H 1 Reply Last reply
          0
          • H Harkamal Singh

            I have a console application spanning multiple methods and functions, and based on a flag value I wish to abort program execution. Is there any other method other than break(which cannot be used always)? Thanks! h.

            V Offline
            V Offline
            Vasudevan Deepak Kumar
            wrote on last edited by
            #5

            Environment.Exit()

            Vasudevan Deepak Kumar Personal Homepage Tech Gossips

            1 Reply Last reply
            0
            • N N a v a n e e t h

              Have you tried Environment.Exit() ? It worked for me


              My Website | Ask smart questions

              H Offline
              H Offline
              Harkamal Singh
              wrote on last edited by
              #6

              Thanks. Environment.Exit() works. I was not aware this function.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups