コード例 #1
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            _activityIndicator.IsRunning = true;

            var photoList = await PhotosBlobStorageService.GetPhotos();

            var firstPhoto = photoList?.FirstOrDefault();

            _title.Text   = firstPhoto?.Title ?? "Photo Not Found";
            _image.Source = ImageSource.FromUri(firstPhoto?.Uri);

            _activityIndicator.IsRunning = false;
            _activityIndicator.IsVisible = false;
        }
コード例 #2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            _activityIndicator.IsRunning = true;

            var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));

            await foreach (var photo in PhotosBlobStorageService.GetPhotos(cancellationTokenSource.Token).ConfigureAwait(false))
            {
                _photoList.Add(photo);

                if (_photoList.Count is 1)
                {
                    var firstPhoto = _photoList.Single();

                    _title.Text   = firstPhoto?.Title ?? "Photo Not Found";
                    _image.Source = ImageSource.FromUri(firstPhoto?.Uri);

                    _activityIndicator.IsRunning = false;
                    _activityIndicator.IsVisible = false;
                }
            }
        }