Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 12-12-2006, 05:22 PM   #1 (permalink)
Forum Novice
 
Join Date: May 2005
Age: 26
Posts: 118
Default 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();  
        }
EvilGrin369 is offline   Reply With Quote
Old 12-12-2006, 06:06 PM   #2 (permalink)
Master of the Internet
 
Join Date: Oct 2005
Age: 45
Posts: 6,283
Default

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.
Malaperth is offline   Reply With Quote
Old 12-12-2006, 06:16 PM   #3 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Age: 27
Posts: 4,824
Default

whats the error?
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 12-12-2006, 06:32 PM   #4 (permalink)
Forum Novice
 
Join Date: May 2005
Age: 26
Posts: 118
Default

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.
EvilGrin369 is offline   Reply With Quote
Old 12-13-2006, 01:13 AM   #5 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

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).
mordero is offline   Reply With Quote
Old 12-13-2006, 02:19 AM   #6 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Age: 27
Posts: 4,824
Default

Seems to me you need to post your code for us to help/
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 12-13-2006, 12:54 PM   #7 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,149
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default

Quote:
Originally Posted by EvilGrin369
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
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline   Reply With Quote
Old 12-13-2006, 01:09 PM   #8 (permalink)
Master of the Internet
 
Join Date: Oct 2005
Age: 45
Posts: 6,283
Default

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 is offline   Reply With Quote
Old 12-13-2006, 01:15 PM   #9 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,149
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default

Quote:
Originally Posted by Malaperth
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
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline   Reply With Quote
Old 12-13-2006, 01:19 PM   #10 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

Well if it works the first time he pushes the button, then he has it spelled the way it needs to be...
mordero is offline   Reply With Quote
Old 12-13-2006, 01:20 PM   #11 (permalink)
Master of the Internet
 
Join Date: Oct 2005
Age: 45
Posts: 6,283
Default

Well, it is definitely the name of the process, or it would not compile...
Malaperth is offline   Reply With Quote
Old 12-13-2006, 04:21 PM   #12 (permalink)
Forum Novice
 
Join Date: May 2005
Age: 26
Posts: 118
Default

No it is "Notepad" was a typo, i didnt copy and paste the code. anyway i got it working.
EvilGrin369 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5