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]
# 1
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.

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2
I'll try this way:


Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.BackgroundWorker1.CancelAsync()
Me.BackgroundWorker2.CancelAsync()
nero.Abort()

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
Me.Dispose()
Application.ExitThread()
Application.Exit()
End Sub

Is it correct?

Quisni at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

Depending on how you are running the Form, you may not need all the code in the Form1_FormClosed event. If you are using the new Visual Basic application framework then you shouldn't need any of the Form1_FormClosed method.

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4
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.
ThanksSmile

Quisni at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 5

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.

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 6

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 Sub

Now 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!

Quisni at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 7

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.

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...