FSCopyObjectAsync hogging the thread?
FSCopyObjectAsync hogging the thread?
- Subject: FSCopyObjectAsync hogging the thread?
- From: Kevin Boyce <email@hidden>
- Date: Tue, 8 Jun 2010 22:01:07 -0400
I'm using FSCopyObjectAsync to copy files while displaying a progress
bar, and it seems less asynchronous than I would have thought. I'm
scheduling it in the main run loop, from the main thread. The copy
works correctly, and both the callbacks and the status calls work to
get the current number of bytes copied, but the UI response becomes
very jumpy.
The callback only occurs irregularly, around once a second (I'm
setting the minimum time to 0.1 seconds), and the timer I use to
update various other parts of my UI is similarly blocked, as are mouse
events to my main run loop. I thought I was pretty closely copying
the sample code, but of course it just sleeps on the run loop where
the operation is scheduled, so I can't really compare.
Is there a buffer size I need to set, or am I doing something else
wrong? Here is the code I use to start the copy:
runLoop = CFRunLoopGetCurrent();
fileOp = FSFileOperationCreate(kCFAllocatorDefault);
if( fileOp )
{
err = FSFileOperationScheduleWithRunLoop(fileOp, runLoop,
kCFRunLoopDefaultMode);
if( !err )
{
clientContext.version = 0;
clientContext.info = (void *) info;
clientContext.retain = NULL;
clientContext.release = NULL;
clientContext.copyDescription = NULL;
// Start the copy
err = FSCopyObjectAsync( fileOp, srcRef, destDirRef, NULL, options,
callbackPtr, 0.1, &clientContext );
}
}
Thanks,
Kevin
_______________________________________________
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