473,785 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

catch notifyicon kill attempt so dispose can run

I have a NotifyIcon application. (c# 2) I want to be able to catch a
kill/shutdown attempt so that I can call Dispose() to remove the icon. I
tried to create an event handler for ApplicationExit and put my icon
dispose call in there, but when process.kill() is called from an outside
app on the notifyicon app, the event doesn't get raised. the app closes
but the icon remains in the tray as dispose was never called.

any ideas?

another way of telling the notifyicon class that it needs to close?
Thanks.
Jul 19 '07 #1
2 5786

"deciacco" <a@awrote in message
news:GO******** *************** *******@giganew s.com...
>I have a NotifyIcon application. (c# 2) I want to be able to catch a
kill/shutdown attempt so that I can call Dispose() to remove the icon. I
tried to create an event handler for ApplicationExit and put my icon
dispose call in there, but when process.kill() is called from an outside
app on the notifyicon app, the event doesn't get raised. the app closes but
the icon remains in the tray as dispose was never called.

any ideas?

another way of telling the notifyicon class that it needs to close?
If TerminateProces s is called, which I guess is what Process.Kill probably
does, *no more code in the targetted process gets to run*. I just had to
work around this problem myself (process being killed, not using NotifyIcon)
and did so by having another process waiting on the process handle of the
first which is signalled when the process ends for any reason, triggering my
cleanup. Not sure how or even if you can do out-of-process cleanup with
shell notification icons though.
>

Thanks.

Jul 19 '07 #2

"deciacco" <a@awrote in message
news:GO******** *************** *******@giganew s.com...
>I have a NotifyIcon application. (c# 2) I want to be able to catch a
kill/shutdown attempt so that I can call Dispose() to remove the icon. I
tried to create an event handler for ApplicationExit and put my icon
dispose call in there, but when process.kill() is called from an outside
app on the notifyicon app, the event doesn't get raised. the app closes but
the icon remains in the tray as dispose was never called.

any ideas?

another way of telling the notifyicon class that it needs to close?
To follow up to my previous message -- the shell itself should wait on the
process handle for each process that has one or more tray icons, and remove
them if the process terminates. That it does not could be considered a bug.
Right now the icon is detected as an orphan and removed the next time the
user interacts with it in any way, like moving the mouse over it.
Jul 19 '07 #3

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

Similar topics

5
7365
by: Phil Galey | last post by:
VB.NET 2002 on Windows 2000 SP 3 When I start my program, the NotifyIcon appears in the tray, as it should. However, when I close the program, the NotifyIcon remains until I hover over it with my mouse. If I don't hover over it to make it disappear and then open the program again, another one is added, resulting in a multiplicity of the icon in the tray. I've even tried setting its Visible property to false, followed by a call to the...
6
3253
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle." exception. The problem is that this exception isn't raised somewhere in a method, so it just shows up, and it causes the application to shut down. Is there anyway how to catch this kinds of exceptions? Can I put somewhere a
10
4841
by: james | last post by:
My app has a notify Icon, but after the app exits, the Icon is still visible, and then when I runthe app multiple times I get multiple icons so that my status bas keeps accumulating them to the point it becomes un-usable. The only fix I have found is to re-boot. Not a godd solution. How do I get this to stop happening? Environment C#, VS.Net 2003, XP Pro Thanks,
2
2926
by: Derrick | last post by:
I've been working on an application which has a NotifyIcon (system tray icon), and a corresponding ContextMenu. I want to be able to update this menu dynamically. However, when I make changes to the menu, it seems to disappear. This only breaks when the context menu is tied to a NotifyIcon - not to any other control. Below is a C# file for a form which should illustrate this (at least it does on my machine!). The same contextmenu is...
23
3083
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally block. But, I prefer to dim them "on the fly" only if needed (save as much resources as possible). A little further... I may wish to create a sqlcommand and datareader object ONLY if certain conditions are met. But, if I want to clean these up in the...
0
1081
by: tim | last post by:
I have an vb application that is started/stopped using the System.Diagnostics.Process class. The application has both a form, and a notifyicon. (The form is displayed when the user clicks the notifyicon, and hidden when the user minimizes the form) The problem I've run into is that Process class is unable to close the application using either the CloseMainWindow() or Close() method, when the form is hidden. It seems that the form's...
8
1767
by: bole2cant | last post by:
When I add a Button to my NotifyIcon program I get the following: An unhandled exception of type 'System.NullReferenceException' occurred in unknown module. Additional information: Object reference not set to an instance of an object. I suspect this is a common novice error but I haven't any idea what I need to do to get this to work. "Help" seems to be geared toward people who have been coding for a couple of years!
3
2093
by: amitkgupta28 | last post by:
Hello All, I am working on .NET based project in Visual C++. I am using notifyIcon tool in my application. I am facing a weird problem. Even after closing the application, the notifyIcon still remain in system tray and remove when I mouse over it. I have a little idea that It can be done using dispose() function but I don't know how to use it in VIsual C++.NET. Thanks in advance for help. Regards, Amit
0
9489
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,...
0
10357
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10101
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
8988
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
7509
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
5396
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
4063
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
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.