You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ok, I did some research, and if you are using HttpClient directly, and not NSUrlSessionHandler this is expected behavior.
My fellow engineer wrote it up in great detail here but in short:
"Once your application leaves the forground, we have to kill outstanding network requests because the threadpool that runs them could be stopped at iOS's whims and that would cause your application to freeze.
You can catch this in a try catch and re-try later.
However, we have a candidate improvement/fix for this, which is described in detail here:
So if I understand correctly you mean that If I use "NSUrlSessionHandler" in my Xamarin forms application (only for iOS) then the HttpClient API call won't get cancelled when the application leaves foreground? And if yes then which one from two approaches should I choose from below.
Approach 1:
// create a background configuration for the application var configuration = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration ("my.app.identifier"); // set any specific requirements in the configuration, in this case, we are downloading a lot of data, do always use wifi configuration.AllowsCellularAccess = true; // create the client using the configuration var client = new HttpClient (new NSUrlSessionHandler (configuration));
Approach 2:
var handler = new NSUrlSessionHandler () { BypassBackgroundSessionCheck = true }; var client = new HttpClient (handler);
Hi @chamons,
So if I understand correctly you mean that If I use "NSUrlSessionHandler" in my Xamarin forms application (only for iOS) then the HttpClient API call won't get cancelled when the application leaves foreground? And if yes then which one from two approaches should I choose from below.
// create a background configuration for the application var configuration = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration ("my.app.identifier"); // set any specific requirements in the configuration, in this case, we are downloading a lot of data, do always use wifi configuration.AllowsCellularAccess = true; // create the client using the configuration var client = new HttpClient (new NSUrlSessionHandler (configuration));
var handler = new NSUrlSessionHandler () { BypassBackgroundSessionCheck = true }; var client = new HttpClient (handler);
Will await your reply.
Thanks.
Originally posted by @muffadal53 in #9176 (comment)
The text was updated successfully, but these errors were encountered: