views:

3548

answers:

1

I noticed that the following banal call from my main thread

[self performSelectorOnMainThread:@selector(rollBar:)
      withObject:nil
      waitUntilDone:false];

was causing [NSThread isMultiThreaded] to report that my app
had become multithreaded. I thought that was only supposed
to happen when you detach a thread, something that queueing
a message within one thread shouldn't need to do.

Any insights?

This question not the same as this one.

Stop the press
My fault, rollBar: called [m_progress_bar incrementBy: 0.5];.
The the pretty, lickable, animating NSProgressIndicator is responsible
for making my app become multithreaded. Which is surprising.
I didn't know that.

Surprisingly, [m_progress_bar usesThreadedAnimation] always
returns NO, even though the bar animates when my app is hung.

+2  A: 

Are you sure about this? I put the following code in my appDelegate's init method:

NSLog(@"Multi-threaded before? %@", [NSThread isMultiThreaded] ? @"Yes" : @"No");
[self performSelectorOnMainThread: @selector(setDelegate:) withObject: self waitUntilDone: NO];
NSLog(@"Multi-threaded after? %@", [NSThread isMultiThreaded] ? @"Yes" : @"No");

and got this result in the console:

2008-10-21 07:26:28.296 MyApplication[82963:20b] Multi-threaded before? No
2008-10-21 07:26:28.297 MyApplication[82963:20b] Multi-threaded after? No

I also added the second NSLog(...) statement to my applicationWillTerminate: method and it also told me it was not multithreaded.

Ben Gottlieb
Thanks, you put me on the right track. The NSProgressIndicator inrollBar: made my app become multithreaded. Who knew!?
Rhythmic Fistman