user609511
user609511

Reputation: 4261

C# in Windows Application Closing or Exit

When I click the X (windows close button on corner top right) is application.exit or this.close run implicitly?

Because every time that I change my programme and compile it, it cannot be compiled because it is in use by another process, So I have to kill it every time on windows task manager.

Because of that, I think that my application not really close / exit properly.

namespace FrontEnd_Offline
{
    public partial class Main_Usr : Form
    {
        public Main_Usr()
        {
            InitializeComponent();
            this.IsMdiContainer = true;
        }

        private void barButtonItem_CreateOrdre_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }

        private void barButtonItem_OrdreListe_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Ordre_Liste f = new Ordre_Liste();
            f.MdiParent = this;

            f.Show();
        }
    }
}

Upvotes: 0

Views: 1459

Answers (2)

Hans Passant
Hans Passant

Reputation: 942368

It is conditional but that's not the problem. All your forms got disposed but your code didn't stop running. The common reasons for this:

  • starting a thread without setting its IsBackground property to true and not ensuring the thread is terminated when your main form closes.
  • using Application.DoEvents() in your code.

You can use Debug + Break All, then Debug + Windows + Threads to see what code is still running. Some of the threads shown there are not your threads so avoid chasing the ones that don't show a good stack trace.

Upvotes: 3

Rohit Vipin Mathews
Rohit Vipin Mathews

Reputation: 11787

You try calling the base.dispose(true) method to fully exit the application. You can write this code into the event of close button. Even though it might not be considered the best of programming practices.

Upvotes: 0

Related Questions