Re: What should we do if file-opening takes a long time?
Re: What should we do if file-opening takes a long time?
- Subject: Re: What should we do if file-opening takes a long time?
- From: Daryle Walker <email@hidden>
- Date: Sat, 14 Jan 2017 04:14:00 -0500
> On Dec 31, 2016, at 9:03 PM, Charles Srstka <email@hidden> wrote:
>
>> On Dec 31, 2016, at 7:35 PM, Graham Cox <email@hidden <mailto:email@hidden>> wrote:
>>
>> NSProgress is thread safe and might be useful for this.
>
> One thing to be careful about when using NSProgress with threads is not to bind directly to it from your UI elements, since the updates will come in on the same thread the changes were made on. Either register your observers manually and call the main thread from -observeValue:forKeyPath:ofObject:change:context:, or have your worker thread call the main thread to update the NSProgress object.
[Just catching up on my e-mail now.]
Yeah, I just read that Cocoa Bindings is generally main-thread only, like the windows and views. I thought I could have a NSProgress subclass that takes a pointer to an existing progress object, KVO’s the heck out of all the remote object's attributes, then updates its own to match, but only posts from the main queue. The initializer would take the remote progress object, but it would also need the queue that the remote does its work on, so the local progress object can pass its cancel/pause/resume up to the remote object, right?
Would I have to KVO every attribute? Or is there a core list so I can use Progress’s included code to handle the rest? I’m also thinking of adding a Boolean flag to indicate completion. (You can’t use fraction-complete attribute since it’s floating-point.)
The “Progress” page has an “isOld” attribute that isn’t documented, also with some undocumented publish & subscribe API. Are those a mistake? Or an obsolete API (and we should use the documented members)?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
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