Beispiel #1
0
        private Task RefreshPlusTile(string offset, GeoLocationCity city)
        {
            int offsetHour = int.Parse(offset);
            var date       = DateTime.Now.AddHours(offsetHour);

            return(LiveTileWeatherProvider.GetForecast(city, date)
                   .ContinueWith <Task>(task =>
            {
                var tcs = new TaskCompletionSource <bool>(TaskCreationOptions.AttachedToParent);

                if (task.IsCompleted)
                {
                    var result = task.Result.FirstOrDefault(x => x.Df.Hour == date.Hour);
                    if (result != null)
                    {
                        var plusTile = CreateTileItem(city, result, TileType.PlusTile);
                        plusTile.Offset = offsetHour;

                        Deployment.Current.Dispatcher.BeginInvoke(
                            () => TileGenerator_RefreshTile(plusTile, () => tcs.SetResult(true)));
                    }
                }

                return tcs.Task;
            }));
        }
Beispiel #2
0
        private Task RefreshLatestTile(GeoLocationCity city)
        {
            return(LiveTileWeatherProvider.GetForecast(city, DateTime.Now)
                   .ContinueWith <Task>(task =>
            {
                var tcs = new TaskCompletionSource <bool>(TaskCreationOptions.AttachedToParent);

                if (task.IsCompleted)
                {
                    var now = task.Result.FirstOrDefault(x => x.Df.Hour == DateTime.Now.Hour);
                    if (now != null)
                    {
                        var latestTile = CreateTileItem(city, now, TileType.Latest);

                        Deployment.Current.Dispatcher.BeginInvoke(
                            () => TileGenerator_RefreshTile(latestTile, () => tcs.SetResult(true)));
                    }
                }

                return tcs.Task;
            }));
        }