RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Kill process method

EvilGrin369

Sorceror
Kill process method

Ok i got my Form to start and stop a process with the start and kill method only thing is after i kill the process and i click the "X" at the top of the form again i get an error. i've tryed alot of method's and no luck any idea's?

Code:
private void button2_Click(object sender, EventArgs e)
        {
            Notpad.Kill();  
        }
 

Malaperth

Wanderer
I can only speak from logic, not coding experience, but it seems to me that you would need to close the Form you created in a process before you kill the process.
 

EvilGrin369

Sorceror
after the close button is clicked once the second time it's clicked and the process is shut down the error is "No process is associated with this object" it close's the process but if it's clicked again it give the error.
 

mordero

Knight
You could put the Notepad.Kill() inside a try{} catch{} or Im sure there is a method for testing if the process is currently active (dont know for sure, just a guess) and just stick it in a if then statement like
Code:
if (process.Running())
process.Kill();
Cause it sounds like the way you have it, you kill the process once by clicking it. Then when you click it again, it isnt running, so its impossible to kill it (thus the error you are getting).
 
EvilGrin369 said:
Ok i got my Form to start and stop a process with the start and kill method only thing is after i kill the process and i click the "X" at the top of the form again i get an error. i've tryed alot of method's and no luck any idea's?

Code:
private void button2_Click(object sender, EventArgs e)
        {
            Notpad.Kill();  
        }

You could try spelling Notepad correctly.

-Storm
 

Malaperth

Wanderer
He said he was using a Form, so I concluded that his Form name was Notpad so as not to be confused with Notepad the program.
 
Malaperth said:
He said he was using a Form, so I concluded that his Form name was Notpad so as not to be confused with Notepad the program.

concluded = assumed; we are not sure if it is the real name of the Form or not. It may be; I may be wrong. But if not, he should probably start using proper names for things or specify what he means by what he says. ;)

-Storm
 
Top