Re: Terminating a thread...
Re: Terminating a thread...
- Subject: Re: Terminating a thread...
- From: Mike Abdullah <email@hidden>
- Date: Mon, 2 Mar 2009 15:07:11 +0000
Have you read the docs on -[NSThread cancel] ? Calling -cancel does
NOT terminate the thread since this easily cause disastrous memory
problems later down the line etc. Instead, your -
convertDatabaseToSQLite3: method should periodically call [[NSThread
currentThread] isCancelled] and finish up early if that returns YES.
Mike.
On 2 Mar 2009, at 14:58, John Cebasek wrote:
Hi All:
I've got an NSThread that copies some data from one database to
another. While the copy is occurring, there's a sheet that is
updated with the progress of the copy. On that sheet there's also a
stop button, so that if the user wants to stop the copy, he can.
I seem to be having some trouble trying to terminate the thread. In
the IBaction for the stop button, I've got:
-(IBAction)closeProgressDialog:(id)sender
{
DebugLog(@"%@", @"ConvertV1Database:closeProgressDialog");
[m_migrateThread cancel];
[self closeProgressDialogSheet];
}
Where m_migrateThread is obtained via:
m_migrateThread = [[NSThread alloc] initWithTarget:self
selector:@selector(convertDatabaseToSQLite3:)
object:nil];
[m_migrateThread start];
Any hints on what I might be doing wrong?
Thanks in advance for your time
John
_______________________________________________
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
_______________________________________________
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