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 protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to