Re: Cancel NSThread - cocoa/mysql database search...
Re: Cancel NSThread - cocoa/mysql database search...
- Subject: Re: Cancel NSThread - cocoa/mysql database search...
- From: spartan g <email@hidden>
- Date: Fri, 8 May 2009 19:38:07 +0530
Thanks...
I tried both the ways as Bill and Mike suggested.
I could manage to cancel the thread by checking the bool flag for
cancellation.
It works fine.
But the problem I am facing now is, once i sent the query to MySQL through
SMySQL framework, I am unable to cancel it. This query takes so much time to
return the results and cannot be canceled as far as I understand.
Is there any way to cancel this query??? any command or API!!!
Once again Thanks guys...
--
Best Regards,
Sparta...
On Wed, May 6, 2009 at 9:34 PM, Bill Bumgarner <email@hidden> wrote:
> On May 6, 2009, at 8:22 AM, Sparta wrote:
>
>> I am working on cocoa – MySQL application that connects to the MySQL
>> database and retrieves the records.
>> I run the search in a NSThread. I wish to cancel the search if needed, as
>> the searching of the desired data takes 15-20 minutes due to the bigger
>> size
>> of database.
>>
>> Please suggest some method which can cancel / exit the NSThread from the
>> parent thread.
>>
>
> Something like this:
>
> ....
> BOOL stopItMan;
> ....
>
> - (void) doSomePotentiallyLongWindedStuffOnASecondThread
> {
> while (!stopItMan) {
> .... do some more stuff ....
> };
> }
>
> - (void) userIsImpatientStopItNow
> {
> stopItMan = YES;
> }
>
> Don't do something like this (which is possible and would require calling
> through to some bits of lower level mach or pthread API):
>
> - (void) userIsImpatientStopItNow
> {
> nukeBackgroundThreadFromSpace();
> }
>
> You can't kill a thread arbitrarily as there is no way to know what state
> the thread might be in when you kill it unless you do the work necessary to
> cause the targeted thread to be blocked at a known safe point in its
> execution. However, if the thread is blocked at a known safe point, that
> known safe point can just as easily be a test to see if should continue,
> exiting safely if not.
> b.bum
_______________________________________________
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