예제 #1
0
        NSUrlSession CreateDownloadSession()
        {
            if (_downloadSession == null)
            {
                string urlSessioinId = Guid.NewGuid().ToString();
                NSUrlSessionConfiguration sessionConfiguration;
                sessionConfiguration = new Version(UIDevice.CurrentDevice.SystemVersion).Major > 7
                    ? NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration(urlSessioinId)
                    : NSUrlSessionConfiguration.BackgroundSessionConfiguration(urlSessioinId);
                sessionConfiguration.TimeoutIntervalForRequest  = Timeout;
                sessionConfiguration.TimeoutIntervalForResource = Timeout;

                var downloadDelegate = new NSUrlDownloadDelegate(OnDownloadCompleted, OnProgress);

                _downloadSession = NSUrlSession.FromConfiguration(sessionConfiguration, downloadDelegate, new NSOperationQueue());
            }

            return(_downloadSession);
        }
        NSUrlSession CreateDownloadSession()
        {
            if (_downloadSession == null)
            {
                string urlSessioinId = Guid.NewGuid().ToString();
                NSUrlSessionConfiguration sessionConfiguration;
                sessionConfiguration = new Version(UIDevice.CurrentDevice.SystemVersion).Major > 7
                    ? NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration(urlSessioinId)
                    : NSUrlSessionConfiguration.BackgroundSessionConfiguration(urlSessioinId);
                sessionConfiguration.TimeoutIntervalForRequest = Timeout;
                sessionConfiguration.TimeoutIntervalForResource = Timeout;

                var downloadDelegate = new NSUrlDownloadDelegate(OnDownloadCompleted, OnProgress);

                _downloadSession = NSUrlSession.FromConfiguration(sessionConfiguration, downloadDelegate, new NSOperationQueue());

            }

            return _downloadSession;
        }