Computer Science Canada Ending a Process? |
Author: | Kelsey [ Thu Jan 06, 2005 6:05 pm ] |
Post subject: | Ending a Process? |
After I use fork to begin running a process, how do I end it? |
Author: | MihaiG [ Thu Jan 06, 2005 6:14 pm ] | ||
Post subject: | |||
possibly
??? |
Author: | Cervantes [ Thu Jan 06, 2005 6:50 pm ] | ||||
Post subject: | |||||
ELCOMANDANTE wrote: possibly
??? Nope. Use return and a flag variable. AsianSensation wrote: Yeah, I should have said it earlier, guess I forgot, sorry. but things like this:
return will terminates the process. |
Author: | Martin [ Thu Jan 06, 2005 6:54 pm ] |
Post subject: | |
Don't use processes. |
Author: | Kelsey [ Thu Jan 06, 2005 7:03 pm ] |
Post subject: | |
martin wrote: Don't use processes.
Then how would you suggest I run a timer in my program? And to the other two of you, thnaks! |
Author: | Cervantes [ Thu Jan 06, 2005 7:10 pm ] |
Post subject: | |
Kelsey wrote: martin wrote: Don't use processes.
Then how would you suggest I run a timer in my program? You could put it in your main loop. What do you mean when you say a "timer", however? A timer since the program has started (or since some event occured)? Time.Elapsed, inside your main loop, will work fine. |
Author: | Kelsey [ Thu Jan 06, 2005 7:17 pm ] |
Post subject: | |
Cervantes wrote: You could put it in your main loop. What do you mean when you say a "timer", however? A timer since the program has started (or since some event occured)? Time.Elapsed, inside your main loop, will work fine. It starts when an even occurs. How do I encorperate Time.Elapsed so it can be outputed in the run window? |
Author: | Cervantes [ Thu Jan 06, 2005 7:24 pm ] | ||||
Post subject: | |||||
huh?
Or, a little more complex:
|
Author: | Martin [ Thu Jan 06, 2005 7:26 pm ] | ||
Post subject: | |||
Well, you have your main loop keep track of the time that has elapsed since the beginning of the program. Each event is then tied to a start time, and has a life, and this is all checked in the main loop. It's much cleaner. In pseudocode:
|
Author: | Kelsey [ Thu Jan 06, 2005 7:28 pm ] | ||||
Post subject: | |||||
Cervantes wrote: huh?
Or, a little more complex:
This doesn't really seem like what I'm trying to do, but thanks for explaining that. Why is it so bad to use processes anyways? |
Author: | Martin [ Thu Jan 06, 2005 7:34 pm ] |
Post subject: | |
Processes behave somewhat inconsistantly and unpredictably, and are often used inefficiently. The basic idea of writing a program is to perform as few calculations as necissary, and when people use processes, 99% of the time, they are calculating something over and over, and only using that calculation a couple of times. |
Author: | Kelsey [ Thu Jan 06, 2005 7:43 pm ] | ||
Post subject: | |||
martin wrote: Processes behave somewhat inconsistantly and unpredictably, and are often used inefficiently.
The basic idea of writing a program is to perform as few calculations as necissary, and when people use processes, 99% of the time, they are calculating something over and over, and only using that calculation a couple of times.
Basically, when you click the button to start the game (Minesweeper), the timer needs to begin. What I wanted to do was end the process when the button is clicked again (it changes to a stop button once the game begins). I have a lot of conditions that need to be checked continuosly throughout the loop, so adding a delay in there for my time to show up every second wouldn't be so great. I think using a process here works ![]() |
Author: | Cervantes [ Thu Jan 06, 2005 8:00 pm ] | ||
Post subject: | |||
Kelsey wrote: I have a lot of conditions that need to be checked continuosly throughout the loop, so adding a delay in there for my time to show up every second wouldn't be so great. I think using a process here works. Nah:
![]() |
Author: | Kelsey [ Thu Jan 06, 2005 8:05 pm ] |
Post subject: | |
Thank-you! |