Hi Jordan, I do normally do that, but with Cocoa bindings, I've bound to my model objects which get updated automatically when the willChangeValue method gets called from the background thread.
I'll try Jens' solution with having two CBLManagers. Thanks! Brendan On Monday, November 16, 2015 at 1:02:57 PM UTC-7, Jordan Wood wrote: > > Why can't you do your UI updates from your custom dispatch queue by > enclosing them in dispatch_async blocks that execute on the main dispatch > queue? > > Jordan > > On Monday, November 16, 2015 at 12:57:29 PM UTC-6, Brendan Duddridge wrote: >> >> I don’t understand … why are you unable? >>> >>> >> If a big database transaction is occurring on the main thread, how can I >> update the UI at the same time? Basically as I'm fetching objects from the >> database, I post notifications or update an NSProgress object which should >> update the UI, but that just doesn't happen if I don't use the >> dispatchQueue. When database access is happening on a background thread, >> I'm able to post notifications to the main thread to update the UI. But if >> database access is happening on the main thread, those notifications don't >> run until after and then it's too late because it's over by then. Basically >> I just see no progress activity until it's done. >> >> I also have bindings to my model objects that display things such as the >> name of a form or the name of a field. So when KVO updates those from a >> background thread, that's where the crashes happen as it's trying to update >> the UI because of the notifications. >> >> Thanks, >> >> Brendan >> >> >> >> On Monday, November 16, 2015 at 9:51:22 AM UTC-7, Jens Alfke wrote: >>> >>> >>> On Nov 15, 2015, at 11:23 PM, Brendan Duddridge <[email protected]> >>> wrote: >>> >>> However, I ran into a problem with replication. Because replication >>> happens on a background thread, the KVO notifications of objects being >>> created isn't happening on the main thread so I'm getting crashes. >>> >>> >>> The notifications happen on the database's thread/queue. So if you’re >>> using a custom dispatchQueue, that’s where the notifications will be >>> delivered. >>> >>> To work around this problem I've stopped using my custom dispatchQueue, >>> but that also means I am unable to update the UI to show progress >>> indicators and status messages. >>> >>> >>> I don’t understand … why are you unable? >>> >>> —Jens >>> >> -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/3ecd56b7-2e60-40b8-8cf1-abf3a6fe1500%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
