chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gavin Cornwell <gavin.cornw...@alfresco.com>
Subject Re: Calling progress/completion block on main thread
Date Wed, 28 Jan 2015 13:01:28 GMT
Hi Peter,

Ah, good question, yes, there was a very good reason. 

NSURLSession uses background threads itself when a request is executed, I 
found that the NSURLSession delegate methods were being called on the 
thread NSURLSession created and not the one you resume the task on.

Without forcing the progress/completion blocks to be run on the main 
thread it meant the ObjectiveCMIS code never got called, every one of our 
unit tests timed out.

We have integrated the library into our SDK and subsequently into the app 
and have not found any issues with this approach so far but I can see how 
this could cause a problem if you’re relying on the old threading 
behaviour of NSURLConnection.

I don’t recall seeing anything in the NSURLSession documentation about 
taming this behaviour but I could be wrong!

Hope that helps,

Regards,

Gavin




On 28/01/2015 12:02, "Sutter, Peter" <peter.sutter@sap.com> wrote:

>Hi Gavin,
>
>I just looked through your changes regarding switch from NSURLConnection
>to NSURLSession.
>I saw that you are calling completion blocks or progress blocks now on the
>main thread. Was there a special reason for it? Because we call the CMIS
>library from a background thread and also expect the completion and
>progress blocks to be executed on the same thread.
>
>Best regards,
>Peter
>
Mime
View raw message