コード例 #1
0
        private async Task ReadFromPCLStorage(CancellationToken token)
        {
            IsBusy = true;

            var getStorageResult = await _localStorageService.PCLReadStorage <WeatherMainModel>();

            if (token.IsCancellationRequested)
            {
                IsBusy = false;
                return;
            }

            if (getStorageResult != null)
            {
                WeatherMainModel = getStorageResult;
                await Task.Delay(3000);

                IsBusy = false;

                if (token.IsCancellationRequested)
                {
                    return;
                }

                await DataWeatherFromGeoLocator();

                OnPropertyChanged();
                WriteToPCLStorage();
            }
            else
            {
                await DataWeatherFromGeoLocator();

                OnPropertyChanged();
                IsBusy = false;
                WriteToPCLStorage();
            }
        }