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 8250873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:03:10+00:00 2026-06-08T00:03:10+00:00

I have a windows forms question: Program.cs: Application.Run(new frmStart()); frmStart: on btnLoad_Click , frmLoad

  • 0

I have a windows forms question:

Program.cs:

Application.Run(new frmStart());

frmStart: on btnLoad_Click,

frmLoad formLoad = new frmLoad();
formLoad.Show();
this.Hide();   // if I do a this.Close();  after it shuts down and doesn't get to show the form

frmLoad: on btnCancel_Click:

Application.Exit();   
// or this.Close(); 
// or even: base.Close();

The form disappears but the program doesn’t end, I still have to press the blue “Stop Debugging” to make it stop.

I have been looking… I know it is possible to make the program really stop, and not just freeze when you close the second form, even if you don’t keep the first form on the screen, but can’t remember and can’t figure out how.

  • 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-06-08T00:03:11+00:00Added an answer on June 8, 2026 at 12:03 am

    Ack, -1 on Application.ExitThread!

    The issue is that you haven’t closed the main form. The simplest way is to hook onto the 2nd form’s Closed event and have it close the main form. For example the code to open the 2nd form changes to:

            var newForm = new frmLoad();
            newForm.FormClosed += (closedSender, closedE) => Close();
            newForm.Show();
            Hide();
    

    This essentially sets up so that when the frmLoad form closes, the main form calls it’s Close() method. I used a Lambda expression for the event handler, but you can just as easily create a private method accepting an (object sender, EventArgs e) and point .FormClosed at it.

    *Edit: Sorry, missed that you only want to close on certain state. In which case on your frmLoad, create a public property such as:

    public bool UserCancelled
    {
    get;
    private set;
    }

    where the Cancel button sets this to True before closing the form. Your event handler in the main form changes to:

            var newForm = new frmLoad();
            newForm.FormClosed += (closedSender, closedE) =>
                                    {
                                        if (newForm.UserCancelled)
                                            Close();
                                    };
            newForm.Show();
            Hide();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

vb.net windows forms question. I've got 3 forms that have exactly the same functions,
I have a windows forms application in .NET 3.5. There's one form with 20
I have a HelpButton on a Windows Forms application. When clicked, I just want
When you open a new C# Windows Forms Application project in Visual Studio 2008,
I'm porting a windows forms program to run on Windows Phone 7. Part of
I have a windows forms based application made by another programmer and I need
(Modifying the question)I have a windows form app in C# which calls into some
A theoretically question: I have a C# Windows Form app, that sends back some
I have Windows Forms UI, that allows me to enter format for string formatting
I have a Windows Forms app in C#/.NET4 with a SQL 2008 back end.

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.