killing a process in task manager
What have I to do if I want to kill a process in my task manager?
My application name is
BackupAll.exe
and it is, obviously, in my tsk manager when it runs.
When I close it, while it is burning a dvd (using nero com object), the form closes but in task manager BackupAll.exe still exists!!
How can I kill it DEFINITEVELY when I close my application?
Is there a simple and effective way?
Thanks!!
Well,if I close my application, while it is NOT burning a dvd (using nero com object), the form closes and in task manager BackupAll.exe disappears.
[715 byte] By [
Quisni] at [2007-12-17]
You probably don't want to force an exit in this situation. Is there a cancel on the nero COM object?
Also you need to make sure that you are calling Marshal.ReleaseComObject on any COM objects you are using once you have finished with them.
Yes, you're right.
I deleted that part of code.
My problem is still there.
How can I kill a process (my application) in task manager?
It is still there even if my form is closed...
I want that, when I close my main form (form1), my application (and any thread originated by it) is killed.
Thanks
Okay there is obviously some sort of object (probably your COM CD burner objects) still floating around.
Try starting off with an empty windows application and keep adding things until your application won't quit and the last thing you have added caused the problem.
Once you have done that, post back here and we will try to solve this.
Thank you very much.
I solved my problem with these lines: Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As_
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
nero.Abort() Me.BackgroundWorker1.CancelAsync()
Me.BackgroundWorker2.CancelAsync()
'deleting definitevely nero com object
Dim y As Integer
y = System.Runtime.InteropServices.Marshal.ReleaseComObject(nero)
Do Until y = 0
y = System.Runtime.InteropServices.Marshal.ReleaseComObject(nero)
Loop
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As_
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
System.Diagnostics.Process.GetCurrentProcess.CloseMainWindow()
System.Diagnostics.Process.GetCurrentProcess.Close()
System.Diagnostics.Process.GetCurrentProcess.Kill()
End SubNow when I close the main window-form (the only one!) all resources are released e process disappears from task manager!
Thank you everybody.
If you have some comments about my solution please let me know!
Yep, you are forcing a shutdown by killing the process.
This is a bad thing, you should never need to call Process.Kill or (CloseMainWindow for that matter).
It's worse than calling Application.Exit().
Also the Process.Close() method simply disposes of the of the process object itself and doesn't 'close' the process.
You really need to track down why your application isn't closing.
Did you try what I suggested above?
Try starting off with an empty windows application and keep adding things until your application won't quit and the last thing you have added caused the problem.