473,387 Members | 1,493 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.

Preventing an exit

I've created some code (without using the form builder) that is extremely
simple. All it does is, in it's constructor, create a NotifyIcon and make it
visible. It also has a ContextMenu that quits the application.

The problem is, while the icon does display in the system tray when I run
the application, it disappears as soon as I put the mouse over it. On closer
inspection, the program just opens then closes immediately - the icon only
disappears when I make Windows update the tray by moving my mouse onto the
taskbar!

I want my app to stay open until I tell it to close.

I was advised to add a Thread that just yields in its loop, to block the
constructor from exiting, but isn't that a workaround? I want my app to lay
dormant until an event occurs (like the user hitting 'Quit' form the
contextmenu). Surely the framework has some method of achieving that?

Any advice hugely appreciated.

- Dave.
Nov 15 '05 #1
1 1072
Can you show us your code? If your Main method is something like:

static public void Main() {
FormX die = new FormX()
die.Show();
}

Then it'll show, then return. You should use Application.Run(new FormX()).

-mike
MVP
"David Johnston" <sp**@spam.spam> wrote in message
news:3f*********************@news.dial.pipex.com.. .
I've created some code (without using the form builder) that is extremely
simple. All it does is, in it's constructor, create a NotifyIcon and make it visible. It also has a ContextMenu that quits the application.

The problem is, while the icon does display in the system tray when I run
the application, it disappears as soon as I put the mouse over it. On closer inspection, the program just opens then closes immediately - the icon only
disappears when I make Windows update the tray by moving my mouse onto the
taskbar!

I want my app to stay open until I tell it to close.

I was advised to add a Thread that just yields in its loop, to block the
constructor from exiting, but isn't that a workaround? I want my app to lay dormant until an event occurs (like the user hitting 'Quit' form the
contextmenu). Surely the framework has some method of achieving that?

Any advice hugely appreciated.

- Dave.

Nov 15 '05 #2

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

Similar topics

7
by: Robb Meade | last post by:
Hi all, A recent project that I had finished and went live with no apparant problems. My client received an email from a user who mentioned that by accident they had been typing (over the...
3
by: ColinWard | last post by:
I am using the following code to validate that the person that is being entered into the database does not already exist. However wnem I test it by entering myself as a contact(I first checked that...
7
by: Joe Ocampo | last post by:
Does anyone know how to prevent multiple applications from being instantiated?
1
by: capb | last post by:
Hello, This is my first post, and any help would be greatly appreciated. I create online memorials which contain guestbooks which have been the subject of computer generated spam. I have been able...
1
by: perspolis | last post by:
Hi all How can I prevent running a program multi times?? thanks in advance
1
by: pcnorb | last post by:
I have a form, pulling data from a Products table that has many fields that do lookups to other tables. These are in a one-to-many relationship to a pk in each of said tables. I'd like to be...
2
by: Brad Baker | last post by:
We have a custom 404 error page setup so that when a 404 is generated the user gets sent to redirect.asp. Redirect.asp sends a user back to default.asp (or any other page specified) One problem...
3
by: Bill Davidson | last post by:
All: I have a problem in which a worker thread in my (.dll) assembly isn't allowing the main (.exe) assembly from terminating. Here's the scenario: 1) App.Exe is launched. 2) App.Exe calls...
7
by: chowdary | last post by:
I am developing a PHP-mysql database. It is noted that when the browser window is refreshed the data is inserted again in the database. unfortunately there is no unique keys that I can use to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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?
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
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,...

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.