Thread and Return key strangeness
Thread and Return key strangeness
- Subject: Thread and Return key strangeness
- From: Lorenzo Puleo <email@hidden>
- Date: Tue, 07 May 2002 15:41:58 +0200
Hi,
I have got a strange trouble launching a NSThread after I pressed the Return
key. I would like to understand what I wrong.
I have a NSTabView with 2 tab items "console" and "preferences".
The table "console" has a button "Start" without equivalent key, that I can
click with the mouse only.
The tab item "preferences" has a button "OK" with the equivalent key "\R".
Clicking on this button with the mouse or pressing the Return key I set the
preferences and go back to the tab item "console".
If I pressed the Return key to go back to the console, and then click on the
button "Start", the thread doesn't run properly. It stops on the line
[consChooseFolderBtn setEnabled:NO];
If I click the "OK" button with the mouse to go back to the console, and
then click on the button "Start", the thread works properly. Why?
The "Start" button launch this routine:
[NSThread detachNewThreadSelector:@selector(StartTask) toTarget:self
withObject:nil];
And the StartTask does that:
- (void)StartTask
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[consChooseFolderBtn setEnabled:NO];
// ... some simple code here (copy files...)
[consChooseFolderBtn setEnabled:YES];
[pool release];
[NSThread exit];
}
Also, if I launch the StartTask routine without thread this way
[self StartTask]
it always runs properly, either if I went back to the console clicking the
"OK" button with the mouse and pressing the Return key.
I am going to became crazy.
Can someone explain this?
Assistance is appreciated.
Also, I would like to find some sample code about NSThread. Where could I
get this?
Thanks.
--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.