Re: FSCopyObjectAsync hogging the thread?
Re: FSCopyObjectAsync hogging the thread?
- Subject: Re: FSCopyObjectAsync hogging the thread?
- From: Graham Cox <email@hidden>
- Date: Wed, 9 Jun 2010 16:43:09 +1000
I'm not familiar with these ops, but having browsed the docs just now, it seems to me what's happening is that because you've scheduled the operation with your main run loop, it's not really "asynchronous" as much as time-sharing with your main loop, which is why your UI is jumpy.
You could try setting up a runloop on another thread to get truly asynchronous copying, and then ensure that the progress update is performed on the main thread as needed.
--Graham
On 09/06/2010, at 12:01 PM, Kevin Boyce wrote:
> 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 );
> }
> }
_______________________________________________
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