locked
prevent from getting application killed from task manager in wpf RRS feed

  • Question

  • How can i prevent my wpf application from getting killed from task manager ???

    I tried a lot and searched a lot on internet, but did not get any break through, please help me out !!!!!

    Thanks in advance...

    Sunday, July 10, 2011 1:30 PM

Answers

  • Hi Amol1987,

    I do not think prevent your application killed from Task manager is a good idea, our operate system manage application by Task manager, if you prevent this behavior, sometime, your application becomes no response, how do we shutdown this application, and we could not restart as well, because our application could not be closed.

    Based on my understanding, user will not close application from Task manager if application provide a close button and works normally.

    If you have to monitor this behavior, I think you could try to use an external application or service to know it.

     

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Sheldon _Xiao Tuesday, July 19, 2011 7:47 AM
    Tuesday, July 12, 2011 5:03 AM

All replies

  • You could disable the posibility of using the Task Manager

    For instance do like this:
    http://www.ehow.com/how_7281455_disable-task-manager-c_.html 


    Developing is part of being a developer.
    Sunday, July 10, 2011 2:20 PM
  • Why would you want to?

    Sunday, July 10, 2011 5:28 PM
  • I need to capture the event coming from O.S, when someone tries to kill my application in task manager. This will show my user a message box, so that he can save his work. Just as when we click close button in MS-Word and we are asked to save our work.

    Monday, July 11, 2011 12:29 PM
  • You can use one of the following.

     

       App.Current.Exit += (sender,e) =>
        {
         MessageBox.Show("Close");
        };
       this.Closing += (sender,e) =>
        {
         //Can be used if you do not want the process the close.
         e.Cancel = true;
         MessageBox.Show("Closing");
        };
    

    When using this.Closing(), it is intended for an element that has the Closing Event. :)

    Enjoy :)

     

     


    Developing is part of being a developer.
    Monday, July 11, 2011 12:48 PM
  • Task manager is Almighty, a process cannot save itself if it is killed by Task manager.

    [If you know concept of dll injection then you can stop task manager from killing your process(by swapping address space of its method to your one) but that is so complex and skilled activity that above mentioned line seems more helpful :)]

    • Proposed as answer by Sheldon _Xiao Tuesday, July 19, 2011 7:47 AM
    Monday, July 11, 2011 1:06 PM
  • Hi Amol1987,

    I do not think prevent your application killed from Task manager is a good idea, our operate system manage application by Task manager, if you prevent this behavior, sometime, your application becomes no response, how do we shutdown this application, and we could not restart as well, because our application could not be closed.

    Based on my understanding, user will not close application from Task manager if application provide a close button and works normally.

    If you have to monitor this behavior, I think you could try to use an external application or service to know it.

     

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Sheldon _Xiao Tuesday, July 19, 2011 7:47 AM
    Tuesday, July 12, 2011 5:03 AM
  • I think the solution to your problem is to stop other people logging onto the same PC.

    Because if there's only me using a PC then nobody else is going to stop my processes unexpectedly.

     

    • Proposed as answer by Sheldon _Xiao Tuesday, July 19, 2011 7:47 AM
    Tuesday, July 12, 2011 9:12 AM
  • Hi Amol1987,

    I am marking your issue as "Answered", if you have new findings about your issue, please let me know.

     

    best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 19, 2011 7:47 AM