473,780 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cleaning up after the process is ended in task manager

I have a problem that relates to running "cleanup" code when an application
is forcibly ended using the "End Process" of "Task Manager" (Please note that
this is very different from "End Task" since end task sends a message to the
application, requesting it to close)

My real problem is that our application makes entries into a database when
the application starts, and then corresponding entries when the application
closes ("cleanup"). This application is run in a terminal session, and
disconnected sessions are forced closed after a certain amount of time has
passed, effectively ending all the processes of the terminal session. This is
equivalent to "End Process" of the application using Task Manager.

I'm unable to run any code when this happens, the code does not return after
the Application.Run (...) statement, so putting a try-catch-finally around it
doesn't work because it isn't run.

Adding event handlers to AppDomain.Proce ssExit doesn't work, nor does adding
a MessageFilter to the Application's message loop.

How do I get code to run under these circumstances ?
Jul 21 '05 #1
4 2017
Hi Jaans,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to write clean up code even
the process is ended by TerminateProces s. If there is any misunderstandin g,
please feel free to let me know.

As far as I know, this cannot be achieved. TerminateProces s is the
low-level process killing function. It bypasses DLL_PROCESS_DET ACH and
anything else in the process. Once you kill with TerminateProces s, no more
user-mode code will run in that process. It's gone. For more information,
please check the following link:

http://weblogs.asp.net/oldnewthing/a...22/191123.aspx

In this case, I think you can do the clean up when process starts. You can
set a flag to see if the process is exit properly. If not, check it at the
beginning of your app, and do clean up.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #2
Hi Kevin

Yes your understanding is correct. Thank you for confirming what I suspected
might not be possible. The link also was helpfull.

This made me think about Terminal Server in particular. Is it issuing a
"TerminateProce ss" to the processes running in a sessions when it has reached
it's disconnected timeout, or is it sending closing the applications some
other way?

We have done some tests (remote debugging), is it's behaviour is similar to
that experienced by "TerminateProce ss".

Why I'm so interested in cleaning up, is that a GUID ticket is issed as a
form of "license control" when the application starts, which needs to be
"returned" when the application closes. I guess I'm going to have to change
it to issue tickets that "expire" or somthing like that.

Regards

"Kevin Yu [MSFT]" wrote:
Hi Jaans,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to write clean up code even
the process is ended by TerminateProces s. If there is any misunderstandin g,
please feel free to let me know.

As far as I know, this cannot be achieved. TerminateProces s is the
low-level process killing function. It bypasses DLL_PROCESS_DET ACH and
anything else in the process. Once you kill with TerminateProces s, no more
user-mode code will run in that process. It's gone. For more information,
please check the following link:

http://weblogs.asp.net/oldnewthing/a...22/191123.aspx

In this case, I think you can do the clean up when process starts. You can
set a flag to see if the process is exit properly. If not, check it at the
beginning of your app, and do clean up.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #3
Hi Jaans,

As far as I know, it is issuing a TerminateProces s. If so, I think you can
try to set timeout to let the ticket expire after a period of time.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #4
Hi Jaans,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #5

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

Similar topics

2
4995
by: RL | last post by:
Hello Perl gurus, 1. I have a web page where I can push a button (dospawn.html). 2. This button calls a CGI script (spawnboss.cgi) 3. spawnboss.cgi calls a forking perl script (forkme.pl) 4. forkme.pl calls the process creation script (createme.pl) 5. createme.pl creates my notepad.exe process, but no window shows up on my PC. The result on my web browser is:
3
5935
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
3
5179
by: Pankaj | last post by:
Hi All: Is there a solution to below problem...without....restarting VS.Net 2003 so may be sometimes restarting PC. // Cannot copy assembly 'MyClient.Client' to file 'C:\bin\Debug\MyClient.Client.dll'. The process cannot access the file because it is being used by another process. -Pankaj
3
9973
by: Vagabond Software | last post by:
Scenario: The end-user selects File-Save from my applications (WinForm) menu, specifies a filename, and waits waits for my app to write the contents of a dataset to an Excel workbook. The SaveXLReport method completes successfully, calls myXLClass.Dispose, and returns control to the user form at a base state. At this point, there is still an EXCEL.EXE in processes and the specified workbook cannot be saved until that process is ended from...
5
2075
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because the c:\bin\xcacls starts nothing happens. How can I see output from the console i was trying to get the ProcessStartInfo.RedirectStandardOutput Property to work but even if I got the system to process it I didn;t know where the output was being...
4
328
by: Jaans | last post by:
I have a problem that relates to running "cleanup" code when an application is forcibly ended using the "End Process" of "Task Manager" (Please note that this is very different from "End Task" since end task sends a message to the application, requesting it to close) My real problem is that our application makes entries into a database when the application starts, and then corresponding entries when the application closes ("cleanup")....
4
15968
by: Strah | last post by:
Is there a way to catch the event of terminating the application from the the processes tab in task manager? I have created windows app, and if a user termintates the app in the task manager, I'd like to be notified. I tried few combinations of Close, Closing, Application.Exit method, ApplicationExit Event, etc, but nothing seems to be working. Thanks in advance Strah@Langan
8
1884
by: NAdir | last post by:
Hi, thank you for your help. My VB.Net application contains a document that the user can refresh at any time. The refresh works fine and needs to loop through few datatables (hundreds of rows). This works fine until I delete some rows in two tables. Just after the delete if I do the refresh there is a huge memory allocated and the time needed to perform the refresh increase, the memory and time continue to increase on each refresh until I...
2
2436
by: Tom Shelton | last post by:
On 2008-04-15, DR <softwareengineer98037@yahoo.comwrote: Where are you seeing that? In the task manager? If so, then you are looking in the wrong place. Let me tell you a little something about windows memory management - just because memory is freed, does not mean that the OS instantly removes it from your process. You need to be looking at the performance counters for this - to find out the actuall amount of memory your using....
0
9636
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
9474
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
10306
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
10139
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
7485
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
6727
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
5373
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...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
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.