Ejemplo n.º 1
0
        /// <summary>
        /// Ticks the asynchronous.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private async void TickAsync(object sender, object e)
        {
            Resultat.Clear();

            if (totalTime > 1)
            {
                timer.Stop();
                if (SearchWord != "")
                {
                    var list = Animals.Where(it => it.AnimalName.Contains(SearchWord.Substring(0, 1).ToUpper() + SearchWord.Substring(1)));

                    foreach (var item in list)
                    {
                        Resultat.Add(item);
                    }

                    timer.Stop();
                }

                else if (TotalLength != HuntedAnimals.Count())
                {
                    try
                    {
                        HuntedAnimals = await ApiCall.Get <ObservableCollection <HuntedAnimal> >("HuntedAnimal/Hunter/1");

                        timer.Stop();
                    }

                    catch (Exception ex)
                    {
                        await Task.Run(() => ReportError.ErrorAsync(ex.Message));
                    }
                }
            }
            totalTime++;
        }