Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5937281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:31:02+00:00 2026-05-22T15:31:02+00:00

I was looking at some other question and then I had this question: Who

  • 0

I was looking at some other question and then I had this question:

  1. Who calls the Main() method?
  2. If I want to exit/quit the application (when I get some exception in the Main() method itself), is it a good idea to use return; statement from the catch block in the Main() method?

    • Please note that I am not starting any thread in the Main() method explicitly. When we start the application, are there any threads start automatically in the background?
    • Application.Exit() does not guarantee an application to quit
    • (EDITED point) Environment.Exit() is another option.

Can use of return; statement to quit the application be a good idea? If no, what are those (subtle) things because of which it may not be good idea?

In comparison, which is the best approach to quit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:31:03+00:00Added an answer on May 22, 2026 at 3:31 pm

    If your application is going to terminate due to an unexpected error, you may wish to use Environment.FailFast which will “crash” the application with a specified message that gets written to the event log and offers the user an opportunity to submit the crash data to Microsoft. As the developer, Microsoft can make the crash data available to you.

    But if you just want to return an error condition to the calling process (such as in the case of a console application) you can modify your Main method signature to return an int and then return a non-zero value which by convention implies an error condition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are some other variations of this question here at SO, but please read
I was looking at some code length metrics other than Lines of Code. Something
What are some saas/web-service methodologies other than the 12-factor app ? I'm not looking
Quick question, looking for some recommendations. I have a site that will be requesting
This is more a quick question on the capabilities of Android. I want to
I know this question has been asked countless times before, but the other threads
This looks very similar to my previous question because it's some sort of follow
I'm fiddling with a bit of c++/opencv. I was looking some of the samples
Looking at some assembly code for x86_64 on my Mac, I see the following
Looking at some of the code System.Linq I've come across some examples of Buffer<TSource>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.