• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Preventing beach balls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Preventing beach balls
      • From: email@hidden
    • Re: Preventing beach balls
      • From: Paul Borokhov <email@hidden>
References: 
 >Preventing beach balls (From: Paul Borokhov <email@hidden>)

  • Prev by Date: Re: what is a valid key-path? why can't I bind to NSURL's -path method?
  • Next by Date: Re: Preventing beach balls
  • Previous by thread: Preventing beach balls
  • Next by thread: Re: Preventing beach balls
  • Index(es):
    • Date
    • Thread