Re: Need help understanding a threading issue

Rick Aurbach

Yes, that was my thinking as well. But, the UI was not frozen. (And, indeed, if it had been frozen, I wouldn't have expected the Notification approach to work either.) 

One additional piece of information I may have inadvertently left out of my original message: using the original approach (of injecting a block into the main queue), I can get the function to work by strategically placing breakpoints in the queued background operations. I don't know whether this means that the breakpoints are interfering with how the queuing works or whether it's a sign of a timing issue or what. I did consider that there was a timing issue and tested that by calling the block with DispatchQueue.main.asyncAfter(..) using a 100ms delay, but that didn't help either.

[This reply has gotten me thinking... I wonder if this has something to do with capture semantics and the fact that the operation that does the dispatch has completed (and therefore was deleted) before the block executed. I could test this by changing the Operation to call a method of a more persistent class (and having that method issue the dispatch call). (If you're following what I'm thinking here.)

I'll try that and let the group know...


Join to automatically receive all group messages.