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

Can an application sense that it's terminating?

If a Windows User decides to kill a process or a separate Windows app calls Process.Kill(), is there any way that the process being killed can see what's going on before it dies? I have a Windows Service that uses some third party dlls which are a bit messy. If the application is improperly closed, all kinds of things start to go wrong, so I want to catch the Kil
command and clean up before dying

It's very likely that what I'm asking isn't possible, but if so, are there any strategies to mimic this behavior? Like a separate process can somehow trigger some flags that the other application checks???
Nov 15 '05 #1
3 1308
AFAIK app has no chance to detect if it is being killed.

Imagine if there would be an event on process kill - the applications can
become immortal

"Jerry" <je************@removethispartdatascientific.com > wrote in message
news:6A**********************************@microsof t.com...
If a Windows User decides to kill a process or a separate Windows app calls Process.Kill(), is there any way that the process being killed can see
what's going on before it dies? I have a Windows Service that uses some
third party dlls which are a bit messy. If the application is improperly
closed, all kinds of things start to go wrong, so I want to catch the Kill command and clean up before dying.

It's very likely that what I'm asking isn't possible, but if so, are there

any strategies to mimic this behavior? Like a separate process can somehow
trigger some flags that the other application checks???
Nov 15 '05 #2
Yep, that's kinda what I was afraid of. Maybe I can solve this problem using Remoting. For instance, the process I want to kill has a remote object exposed that can trigger an event, allowing my process to die gracefully. Thoughts

JER
Nov 15 '05 #3
Sky
If you are looking to ensure that a program cannot be shut down, you have to
create two processes:

....Since you can't kill two processes at the same time via TaskManager...

a) checks to see if b) is still running -- if b) dies, it restarts it, and
viceversa for b)...

Hope that helps.

"Jerry" <je************@removethispartdatascientific.com > wrote in message
news:67**********************************@microsof t.com...
Yep, that's kinda what I was afraid of. Maybe I can solve this problem using Remoting. For instance, the process I want to kill has a remote
object exposed that can trigger an event, allowing my process to die
gracefully. Thoughts?
JER

Nov 15 '05 #4

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

Similar topics

2
by: Byron | last post by:
I'm new to C# and threading, so hopefully this is a simple newbie question. I have a form that is supposed to listen for network traffic on a given port and decode and display any interesting...
8
by: Gaetan | last post by:
Hi let this code : using System; using System.Threading; namespace ThisNamespace { class ThisClass
2
by: Naveen Mukkelli | last post by:
Hi, I'm working on a multi-threaded application. I'm using ThreadPools. One of the requirements of the application is, if certain exception occurs all the counters have to be reset. I have...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
1
by: Dino Buljubasic | last post by:
I have application A and B Application A runs from its main() checks if B exists and if it does, runs application B (which also strarts from its main()). in task manager I can see A.exe and...
2
by: james | last post by:
Is there any way to use Application.Restart() with new command line options? In the documentation on msdn they say Application.Restart() reuses the original arguments. THanks, James
0
by: xievvv | last post by:
I have a C# application that I'm developing that I want to keep unauthorized users (ones that don't have admin priveleges) from terminating. How would I go about doing this? I don't want them to be...
4
by: federico | last post by:
Hello, I am trying to setup a Visual Basic "Console" application for searching Outlook folders. To this end I am trying to implement a Handler for the Outlook.Application.AdvancedSearchComplete...
3
by: =?Utf-8?B?TWFya19C?= | last post by:
I have a usb device that controls a power supply. That usb device must perform a procedure, named Zero_outputs(), in the event of any error. Clearly, within my main form (the only form in this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.