Re: To thread or not to thread?
Re: To thread or not to thread?
- Subject: Re: To thread or not to thread?
- From: Andrew Thompson <email@hidden>
- Date: Mon, 30 Jan 2006 10:51:45 -0800
On Jan 30, 2006, at 1:05 AM, Dado Colussi wrote:
Jeremy Hubbell wrote:
I have a simple function that randomly generates color values that
I'd like to execute when a checkbox is enabled and terminates when
the checkbox is unchecked. I tried a while loop using [sender state
== 1]
Not to thread.
How about using an NSTimer to fire randomly? Set the first expiration
time randomly and the interval to some long time. When the timer
expires, it calls your handler function that does the color thing if
the checkbox is checked and otherwise does nothing. Then readjust the
next expiration time to a random time in the future at the end of your
timer handler function.
I'm curious, why have it fire randomly?
My method would be to set the timer (with a .01 expiration time)
when the checkbox is enabled, do one iteration of generating colors,
then if the checkbox is still enabled, set the timer again with a .01
expiration time.
I'm not sure if this method is the best, but it seems simpler to me.
~Andrew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden