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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to cocoa...@mikeabdullah.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to