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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:41:31+00:00 2026-05-30T03:41:31+00:00

After 2+ hours of looking WHY my bloody process would not exit when I

  • 0

After 2+ hours of looking WHY my bloody process would not exit when I closed the window. I finaly found out that it was the problem in the main window(and not in a thread, because that could have been also the problem)! But I still got NO idea why it bugs.

So THIS code makes it bug:

private void Window_Closing(object sender, CancelEventArgs e)
{
    try
    {
        MessageBox.Show(e.Cancel.ToString()); // False always

        if (formcontroler.formchampinfo != null) // THIS IS NULL so it won t go into this IF
        {
            formcontroler.formchampinfo.Close(); // never gets here so it doesn t matter what this do right ?
        }

        MessageBox.Show(e.Cancel.ToString()); // always false, just to check or it would get to this part tbh
    }
    catch (Exception ex)
    {
        throw (ex); // never gets thrown
    }
}

WHICH IS REALY Strange (to me)! because it gets to the 2nd messagebox and the e.cancel = FALSE so it should not cancel it and just shutdown and the process should get killed(and Visual studio should stop debugging).

Anyway it doesn t stop. It just keeps the process alife and I got no clue why, If I remove the middle if or replace it with a simpler one like:

private void Window_Closing(object sender, CancelEventArgs e)
{
    try
    {
        MessageBox.Show(e.Cancel.ToString()); // False always

        if (true == true) // just To test ofc
        {
            int lol = 5;
            lol++;
        }

        MessageBox.Show(e.Cancel.ToString()); // always false, just to check or it would get to this part tbh
    }
    catch (Exception ex)
    {
        throw (ex); // never gets thrown
    }
}

then it works and the program exits like it should(the process is killed and Visual studio stops debugging.

Some side code that shoudn t mattter I think

class formcontroler
{
    public static frmchampinfo formchampinfo;
}

The frmchampinfo is a window, but atm I loaded it or declaterded it (like formchampinfo = new frmchaminfo();)
Is this a bug or what happened here ? I realy don t get why it doesn t shutdown totaly at my code.

SOLVED sorry I can t answer it until 7 hours but then I am asleep.(Because I don t got 100 rep yet)

Oke so after looking deeper and deeper I found out that the IF statement creates an other form in my formcontroller class(sorry I didn t provide full code in answer so you coudn t figure it out):

class formcontroler
        {
          public static frmchampinfo formchampinfo;
            public static Window activeform;
            public static frmlog formlog = new frmlog();
    //... more code blabla
        }

The formlog “gets made” here. If I add formcontroller.formlog.close() to the code then it can close completly.

 private void Window_Closing(object sender, CancelEventArgs e)
        {
            try
            {
                MessageBox.Show(e.Cancel.ToString()); // False always
                if (formcontroler.formchampinfo != null) // THIS IS NULL so it won t go into this IF
                {
                    formcontroler.formchampinfo.Close(); // never gets here so it doesn t matter what this do right ?

                }
               formcontroler.formlog.Close(); // THIS FIXED IT... lame sorry for all your time. HoweveR I have learned something hope you did too.
                MessageBox.Show(e.Cancel.ToString()); // always false, just to check or it would get to this part tbh
            }
            catch (Exception ex)
            {
                throw (ex); // never gets thrown
            }
        }
  • 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-30T03:41:33+00:00Added an answer on May 30, 2026 at 3:41 am

    Check if the ShutdownMode of your App class is set to OnMainWindowClose.

    You can also explicitly shutdown the application by:

     Application.Current.Shutdown();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

after hours of googeling and searching within SO, I finaly come to the place
I am asking for help, after hours of trying to figure this out myself.
This is either dead simple or can't be done, but after hours of looking
I'm really new to python and after several hours of looking I haven't been
I want to store some information in the local browser cookie. After hours looking
After many hours of googling I thought I would see if anyone knew the
Edit After spending several hours on this and working with @pst, it turns out
First of all, to get this out of the way, I've spent hours looking
after hours of tracking mysterious one or two seconds long lasting freeze I finally
After hours I am giving up on debugging the following: This works: URL[] urls

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.