Re: beginSheet, doesn't stop NSThread
Re: beginSheet, doesn't stop NSThread
- Subject: Re: beginSheet, doesn't stop NSThread
- From: Manfred Schwind <email@hidden>
- Date: Fri, 20 Jul 2007 16:25:39 +0200
very intersting, however it doesn't seem to make it. As i start my
thread I've inserted:
[self performSelectorOnMainThread:@selector(displayDialog:)
withObject:nil waitUntilDone:YES];
The dialog window is:
NSOpenPanel *open = [NSOpenPanel openPanel];
[open setCanChooseFiles:NO];
[open setCanChooseDirectories:YES];
[open setAllowsMultipleSelection:NO];
[open beginSheetForDirectory:NSHomeDirectory()
file:nil
modalForWindow:theWindow
modalDelegate:self
didEndSelector:@selector(didEndSaveSheet:returnCode:conextInfo:)
contextInfo:NULL];
But the thread doesn't stop. Maybe it's at the dialog level where
it should halt and continue only until it is closed... dunno...
What am I doing wrong?
That's what Chris said.
You are using a sheet and this is asynchronous. So you function
"displayDialog" is returning from the main thread, but the sheet is
still open. But because the displayDialog method returns, the thread
continues to run.
So you have to synchronize your two threads somehow - e.g. through
locking. An NSConditionLock may be the best choice here.
Your thread should wait for a specific condition on that lock and the
main thread should set that condition when the
didEndSaveSheet:returnCode:conextInfo: is called.
Regards,
Mani
_______________________________________________
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