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

Using ApplicationContext rather than running a form. Application not quitting

While trying to run an ApplicationContext rather than creating a new form, I
noticed that the application never quits.
I stripped the code out of it down to the bone and it still doesnt exit.
I put a break in the OnApplicationExit function, it's never reached
Any idea what i'm missing?

public class MyApplication : ApplicationContext
{

public MyApplication()
{
Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

foobar();
foobar();

ExitThread();
}

private void OnApplicationExit(object o, System.EventArgs e)
{
DoSomething();
}
[STAThread]
static void Main()
{
Application.Run(new MyApplication());
}// function
Aug 7 '06 #1
2 5625
A call to Application.Exit maybe.

Do you call it from somewhere ?

Regards,
Tasos

Chukkalove wrote:
While trying to run an ApplicationContext rather than creating a new form, I
noticed that the application never quits.
I stripped the code out of it down to the bone and it still doesnt exit.
I put a break in the OnApplicationExit function, it's never reached
Any idea what i'm missing?

public class MyApplication : ApplicationContext
{

public MyApplication()
{
Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

foobar();
foobar();

ExitThread();
}

private void OnApplicationExit(object o, System.EventArgs e)
{
DoSomething();
}
[STAThread]
static void Main()
{
Application.Run(new MyApplication());
}// function
Aug 7 '06 #2
I tried microsofts sample code in their ApplicationContext topic. They run
two forms which maintain a form counter on close.
When the form counter reaches zero ExitThread() is called, the
OnApplicationExit function is called and the application closes down.
I dont know if it might be something to do with having opened some forms,
but when i use my own forms I get this problem too.
I maybe don't understand what's going on in the background.
Aug 7 '06 #3

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

Similar topics

13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
0
by: Alireza Haghshenass | last post by:
Dear All, I am facing a problem which I could not solve. I am writing an application which uses a notify icon and a context menu bound to it to show modal dialog forms. When these forms is shown...
0
by: Ralf Gedrat | last post by:
Hello! I have a Application, this throws after some time following exception: Item has already been added. Key in dictionary: "- 1" key being added: "- 1" I use Application.Run with...
1
by: bixbm | last post by:
Hey all, I'm developing a tray application and want the tooltip to display status info but it evidently has a max size of 64 characters. The application uses the ApplicationContext directly since...
1
by: Carlos | last post by:
I'm getting RPC error when I try to register analys32.xll in the VB program. ErrorCode=-2147417851 Message="El servidor lanzó una excepción. (Exception from HRESULT: 0x80010105...
8
by: Gary | last post by:
I'm using an Act database. I was stuck on this a year ago and am still having trouble. I have three bits of code like so : - act.CActAppObj objACT = new act.CActAppObj(); act.CAIBaseView...
3
by: KaNos | last post by:
Hello, I'm programming an C# application which uses Automation. The problem is when I quit the application a ghost of excel is always running (Can be seen in all processes with th task manager)....
5
by: Rajkiran R.B. | last post by:
I want to log in to a website using C# code.. The main aim is to check whether the username and password I provide is correct or not. I used the following code bool somefunction() {...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.