• 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: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)


  • Subject: Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
  • From: Steve Sisak <email@hidden>
  • Date: Mon, 04 Feb 2013 12:52:06 -0500

At 3:58 PM +0800 2/4/13, õöâ¿ôb wrote:
Thanks Mike seem You are right, and I write like this

[self performSelector:@selector(doTheThing) withObject:nil afterDelay:0.5];
it can work correctly.

And thanks for your suggestion

I suspect that if you change

 > >        //Case 3 hang up, HUD not show
 >
 > >        //[self performSelectorOnMainThread:@selector(doTheThing)
 > > withObject:nil waitUntilDone:YES];

to ... waitUntilDone:NO... it will work as well.

It's hard to tell what's going on without looking at more of your code, but this smells a lot like a thread deadlock.

if you're using a lock to protect data shared between your UI and background task and were holding it when you called performSelectorOnMainThread: that's likely the source of the deadlock.

(Your main thread code won't run until you release the lock and you can't release the lock while you're blocked waiting for your main thread code to complete)

It also may be necessary for your main even loop to run a couple times before the HUD does anything.

 > It seems you need to take the time to learn a little about how
 > multithreading works and should be used with Cocoa.

If you haven't already, read the Concurrency Programming Guide:

<http://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html>

this is a good place to start.

HTH,

-Steve

_______________________________________________

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


References: 
 >What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform) (From: 尹佳冀 <email@hidden>)
 >Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform) (From: Mike Abdullah <email@hidden>)
 >Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform) (From: 尹佳冀 <email@hidden>)

  • Prev by Date: Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
  • Next by Date: Binding NSMenu to NSArray
  • Previous by thread: Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)
  • Next by thread: Re: NSString and file system Re: AppleScript in Sandboxed App
  • Index(es):
    • Date
    • Thread