Exemplo n.º 1
0
        NSUrlSession InitSession(UrlSessionDownloadDelegate sessionDownloadDelegate,
                                 NSUrlSessionConfiguration configuration)
        {
            sessionDownloadDelegate.Controller = this;

            using (configuration)
            {
                return(createSession(configuration, sessionDownloadDelegate));
            }
        }
        public DownloadManagerImplementation(UrlSessionDownloadDelegate sessionDownloadDelegate)
        {
            _queue = new List <IDownloadFile> ();

            _session = InitBackgroundSession(sessionDownloadDelegate);

            // Reinitialize tasks that were started before the app was terminated or suspended
            _session.GetTasks2((NSUrlSessionTask[] dataTasks, NSUrlSessionTask[] uploadTasks, NSUrlSessionTask[] downloadTasks) => {
                foreach (var task in downloadTasks)
                {
                    AddFile(new DownloadFileImplementation(task));
                }
            });
        }
Exemplo n.º 3
0
        /**
         * We initialize the background session with the following options
         * - nil as queue: The method, called on events could end up on any thread
         * - Only one connection per host
         */
        NSUrlSession InitBackgroundSession(UrlSessionDownloadDelegate sessionDownloadDelegate)
        {
            sessionDownloadDelegate.Controller = this;

            NSUrlSessionConfiguration configuration;

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                configuration = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration(_identifier);
            }
            else
            {
                configuration = NSUrlSessionConfiguration.BackgroundSessionConfiguration(_identifier);
            }

            return(InitSession(sessionDownloadDelegate, configuration));
        }
        /**
         * We initialize the background session with the following options
         * - nil as queue: The method, called on events could end up on any thread
         * - Only one connection per host
         */
        NSUrlSession InitBackgroundSession(UrlSessionDownloadDelegate sessionDownloadDelegate)
        {
            sessionDownloadDelegate.Controller = this;

            NSUrlSessionConfiguration configuration;

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                using (configuration = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration(_identifier)) {
                    return(createSession(configuration, sessionDownloadDelegate));
                }
            }
            else
            {
                using (configuration = NSUrlSessionConfiguration.BackgroundSessionConfiguration(_identifier)) {
                    return(createSession(configuration, sessionDownloadDelegate));
                };
            }
        }
Exemplo n.º 5
0
        public DownloadManagerImplementation(UrlSessionDownloadDelegate sessionDownloadDelegate,
                                             bool avoidDiscretionaryDownloadInBackground)
        {
            _avoidDiscretionaryDownloadInBackground = avoidDiscretionaryDownloadInBackground;
            _queue = new List <IDownloadFile> ();

            if (avoidDiscretionaryDownloadInBackground)
            {
                _session = InitDefaultSession(sessionDownloadDelegate);
            }

            _backgroundSession = InitBackgroundSession(sessionDownloadDelegate);

            // Reinitialize tasks that were started before the app was terminated or suspended
            _backgroundSession.GetTasks2((dataTasks, uploadTasks, downloadTasks) => {
                foreach (var task in downloadTasks)
                {
                    AddFile(new DownloadFileImplementation(task));
                }
            });
        }
        private NSUrlSession createSession(NSUrlSessionConfiguration configuration, UrlSessionDownloadDelegate sessionDownloadDelegate)
        {
            configuration.HttpMaximumConnectionsPerHost = 1;

            return(NSUrlSession.FromConfiguration(configuration, sessionDownloadDelegate, null));
        }
Exemplo n.º 7
0
 NSUrlSession InitDefaultSession(UrlSessionDownloadDelegate sessionDownloadDelegate)
 {
     return(InitSession(sessionDownloadDelegate, NSUrlSessionConfiguration.DefaultSessionConfiguration));
 }