Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process Kill

Status
Not open for further replies.

lothos12345

Programmer
Mar 8, 2005
40
US
i have written a visual basic.net 2003 application and upon it closing I want it to kill all instances of the application that are running, so I used the code below

Dim proc() as Process
proc = Process.GetProcessesByName("AppName")

For Each SingleProcess as Process in Proc
SingleProcess.Kill
Next


The above code works generally well but there are occasions when it will not close all instances of the application and I am not sure why. If anyone can shed some light as to the reason, it would be greatly appreiciated.

Thanks
 
Do you use a transactional rollback function in your code? It could be when you're killing it, it senses that a transaction hasn't finished so the program doesn't close that process out because it's trying to rollback the changes.

If this thought sounds strange, just know that I'm a DBA and we always think in terms of transactions (changing data).


Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
I have a similar problem and haven't got to the bottom of it yet, but here are a few ways to close an application - don't know pros and cons of these - maybe someone else can shed some light on differences and when to use each one:

1.Process.Kill()
2.Environment.Exit(0)
3.Process.CloseMainWindow()

I makes sure the application is active before trying Environment.Exit(0) - can't remember why just now, but may be important.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top