473,795 Members | 3,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2730
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))
{
TranslateMessag e(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**********@r esearch-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
6544
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? cheers, reed
2
2891
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() Application("fun")="play" Application.UnLock() There is no other code in the ASP application to change the value in the Application variables. It's only set in global.asa and the rest of the application just read it with code similar to this:
121
10185
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 support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
140
7915
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
4568
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 there something wrong in there? -------------------------------------------------------------------- Types A type is a definition for a sequence of storage bits. It gives the meaning of the data stored in memory. If we say that the object a is an
6
2005
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 opinion) is to create a reusable framework that can be applied to similar projects. However I have found that if an abstraction is created first during the development phase, when the implementation is occurring, the functionality or intended behaviour...
4
1308
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 configurable? Finally, if a new app domain is spawned for a single application, does this equate to a totally different application (with its own Application state, and its own Application_Start/Application_End events, etc.)?
4
4531
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 child apps of an IIS application and can be used by multiple users during the application life cycle and for multiple page loads for the same or different page under a root application. What I don't understand and need to know is whether that...
0
1191
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 - querydef is a pass-thru query that calls a stored procedure on a SQL Server 2000 db - set rowsource property of combo box to the just-created querydef
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.