Re: How to kill a thread?
Re: How to kill a thread?
- Subject: Re: How to kill a thread?
- From: Shaun Wexler <email@hidden>
- Date: Sun, 19 Jan 2003 09:55:20 -0800
Try this:
-(void) search
{
id p=[NSAutoreleasePool new];
do {
itemFound = [self do_one_search_loop_iteration];
} while (searching && !itemFound);
[startbutton performSelectorOnMainThread:@selector(setTitle:)
withObject:@"search" waitUntilDone:YES];
[p release];
searching = FALSE;
}
- (IBAction) toggleSearch:(id)sender
{
searching = !searching;
if (searching) {
[startbutton setTitle:@"stop"];
[NSThread detachNewThreadSelector:@selector(search) toTarget:self];
}
You could also implement method called (searchEnded), which would be
called on the main thread, instead of simply resetting the button
title. Then you would know to check the search results.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
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.