Ann,
Application.Run starts the application message loop. It loops until WM_QUIT
is pulled off of the message queue and then the code in the main method
continues after the loop.
In C or C++ application if you don't use a framework such as MFC your
WinMain method will look something like:
[register windows class]
[create main application window]
[show the window]
while (GetMessage( lpMsg, hWnd, 0, 0))
{
TranslateMessage(lpMsg)
DispatchMessage(lpMsg)
}
[cleanup code]
Ofcourse this is very basic form of the message loop. Real application use
little bit more.
The following is very simplistic approximation of what happen in the C#
windows form application too.
[register windows class]
[create main application window]
is realized by instantiating the main form
[show the window] and the message loop
is inside the Application.Run
and the [cleanup code] is the code after the Application.Run.
As you can see there is no reason this code shouldn't be executed.
I think you get confused of what the C++ frameworks do.
Don't forget that main methods is the entry point of C/C++ program, but the
entry point fo one Windows application is WinMain. The frameworks implement
this WinMain method internaly (inside the framework) inside they do all the
dirty work of registering windows classes, etc then they call one "fake"
*main* method that you declare and after all this they start the message
loop. This might be the reason why your application is not allowed to have
code that executes after the application closes.
I just want to make clear that I made up the scenario for the framework
above and this is not how comersila (e.g. MFC or VCL) frameworks works, but
the idea is that they hide a lot of the details and they dictate how the
code should be constructed.
HTH
Stoitcho Goutsev (100) [C# MVP]
"Ann Huxtable" <an**********@research-labs.de> wrote in message
news:dm**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
Code placed after the statement Application.Run() is executed - is there
any reason why this is allowed (I can't see the point of permitting
statements after the "entry point" call) - akin maybe, to allowing
statements after "main" in C/C++