473,791 Members | 3,211 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 2018
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
5936
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
15975
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
9666
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...
1
10147
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
9023
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
7531
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
6770
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
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
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
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.