Re: performSelectorOnMainThread fails second time through
Re: performSelectorOnMainThread fails second time through
- Subject: Re: performSelectorOnMainThread fails second time through
- From: Dave Keck <email@hidden>
- Date: Wed, 8 Dec 2010 01:19:07 -0500
> Now I thought it would be interesting to try those calls before the thread was dispatched, and the terminate one worked, but the run loop stop didn't. I also tried the runloop stop one in my mini test application, and it didn't work there either, so am a bit suspicious of that. Should that kill any application?
No, it shouldn't make your app terminate - it'll just cause
CFRunLoopRunInMode() to return (see the stack trace you posted
earlier.) I was thinking this would cause the
-performSelectorOnMainThread machinery to notice that there was an
enqueued invocation. (Not that this should be necessary, of course.)
On my system, -performSelectorOnMainThread works using a
CFRunLoopSource attached to the main thread's run loop, which is
signaled after -performSelectorOnMainThread has enqueued an object
representing the invocation. I'm thinking -performSelectorOnMainThread
isn't working because either the main thread isn't running in a common
mode, or something's failing with the CFRunLoopSource. Here are some
things to try:
1. Place a breakpoint on the line after the call to
-performSelectorOnMainThread. After this is hit, at the GDB prompt,
enter the following command:
po (void*)CFRunLoopGetMain()
This should print a lot of information. One of the first lines printed
will mention "current mode =". What mode does it say?
2. In the information printed in the last step, do you see a run loop
source mentioned with a callout of "__NSThreadPerformPerform"? (This
is the run loop source mentioned previously.)
3. Stop your program, and set a breakpoint on the
-performSelectorOnMainThread line. Run your program again. When this
breakpoint is hit, before continuing your program, set a breakpoint at
CFRunLoopSourceSignal(). Continue your program. The
CFRunLoopSourceSignal breakpoint should be hit (directly or
indirectly) from within the stack frame of
-performSelectorOnMainThread; is this true?
_______________________________________________
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