Esempio n. 1
0
        NSUrlSession CreateUploadSession()
        {
            if (_uploadSession == 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 uploadDelegate = new NSUrlUploadDelegate(OnUploadCompleted, _behaviors.ReadProgressCallback);

                _uploadSession = NSUrlSession.FromConfiguration(sessionConfiguration, uploadDelegate, new NSOperationQueue());
            }

            return(_uploadSession);
        }
        NSUrlSession CreateUploadSession()
        {
            if (_uploadSession == 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 uploadDelegate = new NSUrlUploadDelegate(OnUploadCompleted, _behaviors.ReadProgressCallback);

                _uploadSession = NSUrlSession.FromConfiguration(sessionConfiguration, uploadDelegate, new NSOperationQueue());
            }

            return _uploadSession;
        }