0

I have a refresh process that runs in the background (just using performInBackground is all) and part of that has db updates so I have a separate MOC for the background thread. I then use the didSave notification to merge in the changes to the main MOC. While the app is refreshing in background, the user can click around the UI.

Mostly works, but i'm seeing some locks every now and then. When I look at the method called before the lock, its something that accesses the main MOC. Nothing in my refresh process accesses this, everything accesses a background MOC. BUT, I was thinking that the changes i make to the background MOC do get merged using the didSave notification. If I try to query one MOC while its doing mergeChangesFromContextDidSaveNotification, would that be the issue? What's the best way around this? I thought I had solved my db issues with a separate MOC for my background thread, but the merge is gonna be an issue right?

4

1 に答える 1