473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

What happens after Application.Run() ?

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++

Dec 1 '05 #1
2 2709
Hi Ann,
Code placed after the statement Application.Run() is executed - is there
any reason why this is allowed Application.Run() is just a normal method, like other methods. You can
place any code after it to do anything you wish to. I don't see any
point why it should not be 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++

What is "statements after main"? In C#, the Main function is the entry
point, not Application.Run.

Thi

Dec 1 '05 #2
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++

Dec 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
2
by: evangeline | last post by:
We have ASP application running on IIS 5.1 and Windows 2000 server. The ASP application has few Application variables setup in global.asa. Something like this: Application.Lock()...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
6
by: Mark Broadbent | last post by:
this might sound like an obvious question but I have found that usually these two evolve at the same time. One of the biggest reasons for creating the abstraction in the first place (in my...
4
by: newjazzharmony | last post by:
I have heard that IIS may decide to spawn one or more additional app domains for a single ASP dot net application. Is this true? Is there a difference in how this works in IIS 5 and IIS 6? Is it...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
0
by: mirandacascade | last post by:
Using Access 2003. For this application when one enters data and clicks a command button, code gets run that does the following: For 5 different combo box controls: - create a querydef -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.