Execute code at the end of the current process?

Is there a way to start a bit of code at the end of the current process?

I want to register some things when the process ends (either through external means, for example, killing it, or terminating in the application itself).

We are talking about a console application written in C #.

Thanks!

+4
source share
2 answers
+4
source

I'm not sure, but something like that will help

Process process = new Process(); . . process.Exited += new EventHandler(myProcess_Exited); process.Start(); private void myProcess_Exited(object sender, System.EventArgs e) { eventHandled = true; customAction(); // your logging stuff here } public void customAction() { // } 

look: Process.Exited Event

0
source

Source: https://habr.com/ru/post/1302743/


All Articles