473,769 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do a trap a process kill attempt?

I want to trap any attempts to kill my C# application and so that I can
execute shutdown code and let the app die gracefully. How can this be done?
Nov 17 '05 #1
4 4696
Peter Steele wrote:
I want to trap any attempts to kill my C# application and so that I can
execute shutdown code and let the app die gracefully. How can this be done?

I think you worry too much, as long as you do the normal cleanup at the
program exit, it should be fine.

Just imagine how could you trap when people shut down the computer, or
power off :-)

John
Nov 17 '05 #2
John Sun wrote:
Peter Steele wrote:
I want to trap any attempts to kill my C# application and so that I
can execute shutdown code and let the app die gracefully. How can this
be done?

I think you worry too much, as long as you do the normal cleanup at the
program exit, it should be fine.

Just imagine how could you trap when people shut down the computer, or
power off :-)

John

You should try brushing up on your event listeners
Nov 17 '05 #3
This is definitely not worrying too much. It is essential that this
application make every best effort to close down cleanly. If someone shuts
the power off, then clearly there's nothing that can be done...

"John Sun" <js***********@ gmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Peter Steele wrote:
I want to trap any attempts to kill my C# application and so that I can
execute shutdown code and let the app die gracefully. How can this be
done?

I think you worry too much, as long as you do the normal cleanup at the
program exit, it should be fine.

Just imagine how could you trap when people shut down the computer, or
power off :-)

John

Nov 17 '05 #4
Subscribe to the AppDomain.Curre ntDomain.Proces sExit event - this gets fired
when the application is terminating cleanly and while all system components,
appdomains, etc. are still functional.

"Peter Steele" <ps*****@z-force.com> wrote in message
news:Ol******** ******@TK2MSFTN GP10.phx.gbl...
I want to trap any attempts to kill my C# application and so that I can
execute shutdown code and let the app die gracefully. How can this be done?

Nov 17 '05 #5

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

Similar topics

5
3516
by: bobdydd | last post by:
Hi Everbody I am trying to trap the error that SHOULD occur when there is no internet connection. Private Sub CmdPayHere_Click() On Error GoTo Err_CmdPayHere_Click Application.FollowHyperlink "http://www.microsoft.com" Err_CmdPayHere_Click: MsgBox "Page Not Available, Check that You ARE online",
1
2785
by: Mullin Yu | last post by:
But, I want is that I can have a Main app that will start a new process or kill one particular or all process. The process will open a console exe. But, I don't want the user to close the console windows by themselves, and force them to use the Main app. If I use Windows Services, I'm not sure can I create one dynamically, and then kill easily. But, if using console application, my following coding is working now. using System;
0
976
by: Sam Marrocco | last post by:
I seem to be having a devil of a time killing a process.... If I launch an applicaton such as notepad.exe as a Process, I can kill it with no problem. However, if I launch a particulare application (it's a shell application that does some lengthy math processing) as a Process and attempt to kill it, the Process returns properly with an Exited event, but the shell window continues to be open and processing. My guess is that this math app...
5
7330
by: Brett | last post by:
How do I gracefully kill a process than restart it? The process Image Name is known. Thanks, Brett
16
4552
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy Excel process, it still hangs in the taks manager' Processes as running. I am trying very simple code (see below), but Excel wont go away, I tried just about anything I could find on MSDN or by Google. Even calling WIN32 API to destroy Excel. But...
22
5072
by: nd02tsk | last post by:
Hello! I have a couple of final ( I hope, for your sake ) questions regarding PostgreSQL. I understand PostgreSQL uses processes rather than threads. I found this statement in the archives: "The developers agree that multiple processes provide more benefits (mostly in stability and robustness) than costs (more
10
2361
by: pemo | last post by:
As far as I understand it, a trap representation means something like - an uninitialised automatic variable might /implicitly/ hold a bit-pattern that, if read, *might* cause a 'trap' (I'm not sure what 'a trap' means here - anyone?). I also read into this that, an *initialised* automatic variable, may never hold a bit pattern that might, when read, cause a 'trap'. I.e., if an auto is explicitly initialised, it may *never* hold a...
1
1530
by: Newbie Coder | last post by:
In C++.NET 2003 Windows Forms App I fill a ListView control with process name & second column is the Process ID. I would like to kill the selected process, which is simple in VB.NET or C#, but cannot work it out in C++. In VB.NET, I'd do the following:
4
20781
by: Richard Rossel | last post by:
Hi Fellows, I have a problem with process termination. I have a python code that apache runs through a django interface. The code is very simple, first, it creates a process with the subprocess.Popen call, and afterwards, (using a web request) the python code uses the PID of the previously created process(stored in a db) and kills it with an os.kill call using the SIGKILL signal. The creation of the process is ok, apache calls the...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10049
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
9998
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
9865
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
8876
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
7413
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
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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...
2
3567
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.