Strange that all of the code in Closing isn't being run. But isn't the case
that Application.Run() in main() is a blocking call and therefore when the
main form is closed, code after Application.Run() will execute?

static void main()
{
        // blocking call
        Application.Run(new MainForm());

        // mainform is closed
        Shutdown();
}

Ron
-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Jekke Bladt
Sent: Tuesday, June 05, 2007 4:43 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOTNET] Guaranteeing code will run at shutdown

All--

I have a WinForms application that must run a certain block of code before
shutting down. (Obviously, crashes can't be helped. I'm talking about
orderly shutdowns.) Shutdown is triggered by the closing of a main form and
the shutdown code currently executes in the handler for the main form's
.Closing event handler.

However, the application often seems to close before all of the code in the
.Closing handler. Is there any way to prevent this?

TIA

--Jekke

===================================
This list is hosted by DevelopMentor.  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to