예제 #1
0
        public IEnumerable<FeaturedMovies> GetFeaturedMovies(out IExpirationTrigger expirationTrigger)
        {
            _featuredMoviesTokenSource = new CancellationTokenSource();

            expirationTrigger = new CancellationTokenTrigger(_featuredMoviesTokenSource.Token);
            return GetMovies().OrderBy(m => m.Rank).Take(2);
        }
예제 #2
0
 public string GetProducts(string category, out IExpirationTrigger trigger)
 {
     var token = _tokenSource.IsCancellationRequested ? CancellationToken.None :
                                                        _tokenSource.Token;
     trigger = new CancellationTokenTrigger(token);
     if (category == "Books")
     {
         return "Book1, Book2";
     }
     else
     {
         return "Laptops";
     }
 }
예제 #3
0
        public string GetCriticsQuote(out IExpirationTrigger trigger)
        {
            _quotesTokenSource = new CancellationTokenSource();

            var quotes = new[]
            {
                "A must see for iguana lovers everywhere",
                "Slightly better than watching paint dry",
                "Never felt more relieved seeing the credits roll",
                "Bravo!"
            };

            trigger = new CancellationTokenTrigger(_quotesTokenSource.Token);
            return quotes[_random.Next(0, quotes.Length)];
        }