473,320 Members | 1,991 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,320 software developers and data experts.

Form Termination

Hi,

I am writing Forms application, at certain situations I need to prematurely
close it, e.g. upon invalid initialization the App should be closed, using
....Form.Close from the forms constructor doesn't help, I wonder... Is there
an equivalent to the C++ PostQuitMessage(0) in C#? What is it?

ThanX
Nadav.
Nov 15 '05 #1
2 3201
I think Application.Exit will do the trick
"Nadav" <No*@Today.maybe.tommorow> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hi,

I am writing Forms application, at certain situations I need to prematurely close it, e.g. upon invalid initialization the App should be closed, using
...Form.Close from the forms constructor doesn't help, I wonder... Is there an equivalent to the C++ PostQuitMessage(0) in C#? What is it?

ThanX
Nadav.

Nov 15 '05 #2
Hi Nadav,

Application.Exit() terminates the application.

One suggestion to handle the scenario you describe is to throw an exception
in
your form's constructor, then trap that exception in your app's
Main() entry point method.
If an exception is thrown, do not call Application.Run() to run the
message loop and just return from Main() without loading the form.

Regards,
Aravind C
"Nadav" <No*@Today.maybe.tommorow> wrote in message
news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hi,

I am writing Forms application, at certain situations I need to prematurely close it, e.g. upon invalid initialization the App should be closed, using
...Form.Close from the forms constructor doesn't help, I wonder... Is there an equivalent to the C++ PostQuitMessage(0) in C#? What is it?

ThanX
Nadav.

Nov 15 '05 #3

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

Similar topics

2
by: Alan Little | last post by:
I could swear I remember seeing a function that would allow you to specify code to be executed upon termination of a PHP script, but now I can't find anything on it. Anyone know of anything like...
1
by: R6_2003 | last post by:
Hello all, i dunno if that's the right newsgroup to ask, but i'll try, please ignore me if u feel its not 0:) i've been messing with a control panel app for so long.. previously i was using...
2
by: Jim McGrail | last post by:
Background: I am investigating a problem involving a windows .NET application that is being developed in C# with Visual Studio 2003. It is a multi-threaded application that uses MSMQ to...
5
by: Seong-Kook Shin | last post by:
Hi, I'm reading Steve's "C Programming FAQs" in book version, and have two question regarding to Q11.16 ... Also, a `return' from `main' cannot be expected to work if data local to main might be...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
9
by: ehabaziz2001 | last post by:
I am facing that error message with no idea WHY the reason ? "Abnormal program termination" E:\programs\c_lang\iti01\tc201\ch06\ownarr01o01 Enter a number : 25 More numbers (y/n)? y...
2
by: Mike | last post by:
Hello, Ok I have 2 classes in my project, one is the main form and one is a connection class, at a certain event on my main form a new instance is made of the connection class, and a reference...
0
by: Rainman | last post by:
Hi! I'm new here, and I had my first encounter with this site yesterday, when I shamelessly copied Killer42's excellent code for reading a file using the Get method. Thanks! :-) It worked like a...
3
by: angi35 | last post by:
Working in Access 2000... I have a form with records for every employee. I'd like to create two command buttons so a user can filter the form for either 'only current' or 'only former' employees. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.