none
Process.Kill waits 10 seconds RRS feed

  • Question

  • Hi,
     
    I am using the Process.Kill method to terminate processes.  If those processes are in the middle of long running, CPU intensive calculations then it takes 10 seconds - and that time doesn't visibly vary at all - for the process to actually terminate.  Is there a way of making immediate termination mean immediate?

    Michael
    Tuesday, September 16, 2008 8:56 AM

Answers

  • Nah, Process.Kill() direct calls TerminateProcess(), there's nothing friendly about it.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, September 22, 2008 7:34 AM
    Wednesday, September 17, 2008 9:44 AM
    Moderator

All replies

  • You should probably try this first with the usual assortion of anti-malware software disabled.  The generic explanation is that processes cannot terminate until all their I/O requests are completed.
    Hans Passant.
    Tuesday, September 16, 2008 8:03 PM
    Moderator
  • It might be difficult to turn all that stuff off in a network environment, but I guess I can give it a go.

    It's the timing I'm suspect of though.  It's never 9 seconds and it's never 11 seconds, it's always 10 seconds.  That to me says that the OS is trying to persuade it to terminate in something approaching a friendly manner, gives it 10 seconds grace and then blasts it.  If it were an I/O issue surely there would be more variation in the time?
    Wednesday, September 17, 2008 8:41 AM
  • Nah, Process.Kill() direct calls TerminateProcess(), there's nothing friendly about it.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, September 22, 2008 7:34 AM
    Wednesday, September 17, 2008 9:44 AM
    Moderator