I have a main thread method that allocates an NSThread object and inits with initWithTarget:selector:object. I then invoke the NSTask instance with -start.

The specified selector is invoked, and there performs a background task that takes some time. When it is done, that method invokes a callback using performSelectorOnMainThread:withObject:waitUntilDone. That callback selector updates the applications U/I to reflect the outcome of the background task.

After invoking the callback, the background task method cleans up, releases its autorelease pool, and then control reaches the end of the method. I am under the impression that having the method reach the end is sufficient to have the thread end. Is that correct? or do I need to invoke the thread instance with -exit ?

Big question: how do I release the memory associated with the allocated task instance? I have two notions:

1) have the main thread callback autorelease the thread instance

2) have the thread autorelease itself at the end of the background task method after it invokes the callback (which is invokes with ...waitUntilDone:YES).

I know I am treading in dangerous waters with threads... but the background activity can take many seconds, and I want the U/I responsive while the background activity is being performed.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to