
Signature
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
> - (void)mounterThread:(id)arg
> {
[quoted text clipped - 12 lines]
>
> Something like that, anyway. Just typed into MTNW without testing.
Oh, I see. Thanks.
Does main thread execution stop until that new thread is complete? I only
ask because the commands immediately following [self mountNetworkShare]
musn't be executed until it's finished mounting (or at least trying to
mount) the share.
Is that what the 'waitUntilDone:YES' bit does?
Again, thank you.
Jim

Signature
http://www.ursaMinorBeta.co.uk http://twitter.com/GreyAreaUK
"Sometimes when I talk to a Windows person about using a Mac,
I feel like I'm explaining Van Halen to a horse." Merlin Mann
Allen Brunson - 29 May 2008 17:10 GMT
> Does main thread execution stop until that new thread is complete?
if it did, there would be no point in launching the thread!
> I only ask because the commands immediately following
> [self mountNetworkShare] musn't be executed until it's finished
> mounting (or at least trying to mount) the share.
in that case, you’ll have to arrange for the background thread to send a
signal to your foreground thread, letting it know when it can continue doing
what it was up to. sending an event that your app responds to would be a good
idea.
> Is that what the 'waitUntilDone:YES' bit does?
nope.
Jim - 29 May 2008 17:16 GMT
>> Does main thread execution stop until that new thread is complete?
>
> if it did, there would be no point in launching the thread!
Heh. Yes, good point.
>> I only ask because the commands immediately following
>> [self mountNetworkShare] musn't be executed until it's finished
[quoted text clipped - 4 lines]
> what it was up to. sending an event that your app responds to would be a good
> idea.
I've started investigating [[NSThread alloc] initWith...] instead. After
I've executed [myThread start] I thought I could test to see if it's
finished with either [myThread isExecuting] or [myThread isFinished] but I'm
getting odd results from those. Probably me just being too hasty.
You've certainly given me somethinig to think about, thank you :-)
Jim

Signature
http://www.ursaMinorBeta.co.uk http://twitter.com/GreyAreaUK
"Sometimes when I talk to a Windows person about using a Mac,
I feel like I'm explaining Van Halen to a horse." Merlin Mann
Gregory Weston - 29 May 2008 18:31 GMT
> >> Does main thread execution stop until that new thread is complete?
> >
[quoted text clipped - 17 lines]
> finished with either [myThread isExecuting] or [myThread isFinished] but I'm
> getting odd results from those. Probably me just being too hasty.
Yeah. Don't do that. Polling is bad. See my other message for ideas on
having the thread either trigger or directly perform the follow-up code
when it's time.
G

Signature
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
Gregory Weston - 29 May 2008 18:29 GMT
> > - (void)mounterThread:(id)arg
> > {
[quoted text clipped - 16 lines]
>
> Does main thread execution stop until that new thread is complete?
No. That's the point of threads and that's why it fixes your problem
with the text field updating.
> I only
> ask because the commands immediately following [self mountNetworkShare]
> musn't be executed until it's finished mounting (or at least trying to
> mount) the share.
Ah. In that case, you have a few options. The easiest one, although it
might not be the best, is to move those lines into the thread method.
The most flexible is to perform those follow-up lines in their own
method called, say:
- (void)mountAttemptFinished:(NSNotification*)n
{
// Do stuff.
}
Then at some point before your thread launches register that method as a
handler for a notification you've invented, and end the mounterThread:
method with code to issue that same notification. You can even pass
information along in that notification to signal whether or not the
mount succeeded (or just about anything else you might want to
communicate).
> Is that what the 'waitUntilDone:YES' bit does?
No. That prevents the worker thread from continuing until the text field
has been blanked (although not necessarily requiring that it refresh to
reflect that).

Signature
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix
Jim - 29 May 2008 18:41 GMT
> > I only
> > ask because the commands immediately following [self mountNetworkShare]
[quoted text clipped - 18 lines]
> mount succeeded (or just about anything else you might want to
> communicate).
Right-o, thanks.
> > Is that what the 'waitUntilDone:YES' bit does?
>
> No. That prevents the worker thread from continuing until the text field
> has been blanked (although not necessarily requiring that it refresh to
> reflect that).
Gotcha. Silly question in hindsight :-)
Jim

Signature
'Cloverfield' in nine words: "What is it?!" "We're gonna die!" BOOM!
Roll credits.
http://www.ursaminorbeta.co.uk http://twitter.com/greyareauk