Re: NSMatrix mouse puzzle
Re: NSMatrix mouse puzzle
- Subject: Re: NSMatrix mouse puzzle
- From: Graham Cox <email@hidden>
- Date: Thu, 4 Sep 2008 14:52:08 +1000
On 4 Sep 2008, at 2:40 pm, D.K. Johnston wrote:
// wait 10 seconds
NSUInteger i = 0, resume = time( nil ) + 10;
while( i < resume )
index = time( nil );
Don't do this!
This is not a good way to wait for a period of time, even if waiting
for a period of time were a good way to do what you want (which it
isn't). All this does is chew up CPU time - events will still be
captured and queued while this is running, so when it ends, they just
get processed and passed to the now enabled control. Also, as posted
the above code never terminates - i is never changed.
What's to say your "data display" always takes 10 seconds anyway?
Depends on the data, the machine you're running on, etc, etc... time
delay loops are what a first-timer using BASIC uses - real programmers
never do this.
Disable the matrix at the start of data load. When the data load
finishes, signal that fact to some object that re-enables the control.
Load the data asynchronously (using a thread or timer-driven loop).
hth,
Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden