Can processes be used in this way?
Author |
Message |
richcash
|
Posted: Mon Aug 14, 2006 12:34 am Post subject: Can processes be used in this way? |
|
|
Well, I know that processes are ugliest, worst organized, most inaccurate subprogram invented, and I agree that 90% of the time they are improperly used, but I think maybe you can use them when you want the user to interact with the mouse to choose settings or select a gamepiece and move. If you want to load something like pictures (especially SLOW rotated pictures), do advanced calculations, or do recursion that takes a long time (chess, maybe checkers), you can do some, most, or all of it while the user is interacting with another part of the program with the mouse (not keyboard!).
For example, like this :
code: | process Calc
Time.Delay (5000)
%The delay can be replaced with time-consuming calculations or loading
end Calc
process userinput
var x, y, button, num_Clicked : int
loop
Mouse.Where (x, y, button)
locate (1, 1)
put x, " ", y, " ", button
if button not= 0 then
exit
end if
end loop
end userinput
fork Calc
fork userinput |
If you click before 5 seconds is up, it waits the remainder of 5 seconds and exits, if you click after the 5 seconds is up, it exits immediately.
So, am I right, can processes be used for this, or might it ruin the recursion, loading, or calculations? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Mon Aug 14, 2006 7:36 am Post subject: (No subject) |
|
|
You're right. Threading is good for performing calculations while waiting for input or other execution halting things. |
|
|
|
|
|
|
|