Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Is there any method in c# which can trigger when I kill a process using task manager?

I have a windows forms application and i need to write few items to a log file when the user kills the application from task manager. How can I achieve this?

Note: Even though FormClosingEventArgs in Form1_FormClosing event has the TaskManagerClosing functionality but that is not getting triggered while ending the task from task manager. Given below is my code segment written under Form1_FormClosing event.

switch (e.CloseReason)
        {
            case CloseReason.TaskManagerClosing:
                Writer.Log("xyz: " + xyz);
                break;

        }

Comments