Is there is any event handler for process kill event ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am looking for doing this :

void OnKillProcess()
{
do Cleanup;
}

i don't want to use ~MyClass() (or Finalize), because i wan't that
the cleanup code will be call from my main thread and not from any other
thread.

thanks.
 
Hi Ignacio Machin,

I am writing C# Console application and not WinForms application, because i
saw that the application class is part of the syste.windows.forms namespace.
i tried to use it in console application and it didn't work.

thanks.
 
Add a reference to System.Windows.Forms.dll to get access to the Application
class.

Brendan
 
This event is not raised as a result of a 'kill' command, note also that
Console applications can't use this event either, only applications that
have a message loop can register for this event, and the event is fired as a
result of Application.Exit to be called.
Willy.
 
There is nothing yu can do when a process gets killed ( a result of a
ApplicationExit call), the process simply disappears without any possibility
to execute any code.

Willy.
 
Hi Willy Denoyette,

so if i understand you, the one and only option for console app is to put my
cleanup code in ~MyClass() ?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top