Re: Preventing beach balls
Re: Preventing beach balls
- Subject: Re: Preventing beach balls
- From: Seth Willits <email@hidden>
- Date: Sun, 18 Feb 2007 17:14:06 -0800
On Feb 18, 2007, at 5:03 PM, Paul Borokhov wrote:
I'm trying to find a relatively _easy_ solution to prevent
beachballing in my application. I did take a look at threading, but
all of the provided examples seem to imply inter-object
communication with ports and proxies, whereas I don't need anything
near as complicated in my application. I just want to be able to
execute [self foo] and yet leave the interface responsive at all
times. All I need is something like (oneway void), but that has no
effect on calls made by the object to itself...so, any other
solutions?
Threads do not necessitate proxies and ports and all that stuff. You
probably looked at the distributed objects docs which are not the
same thing. All you need is
- (void)whatever;
{
[NSThread detachNewThreadSelector:@selector(threadedWhatever:)
toTarget:self withObject:nil];
}
- (void)threadedWhatever:(id)obj;
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
... do whatever ...
[pool release];
}
Naturally if you need to communicate with other threads, you'll need
to do that (performSelectorOnMainThread:withObject: will probably
work most of the time), and if you use objects on multiple threads
you need to use techniques to keep them safe (Yay NSRecursive lock),
but it's basically that simple.
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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