Esempio n. 1
0
        private static async Task ComparePrice()
        {
            while (!CancelToken)
            {
                try
                {
                    DogeCoinObj dogeCoin = await GetDogeCoinData();

                    if (dogeCoin == null)
                    {
                        throw new Exception("DOGECOIN KONNTE NICHT ABGERUFEN WERDEN");
                    }

                    double currentPrice = dogeCoin.data.prices[0].price;
                    if (currentPrice < Price)
                    {
                        new ToastContentBuilder()
                        .AddArgument("action", "viewConversation")
                        .AddText("DogeCoin Price Alert")
                        .AddText($"Preis liegt bei {currentPrice}, vorheriger Preis {Price}")
                        .Show();
                    }
                    Price = currentPrice;
                    await Task.Delay(Stunde);
                }
                catch (Exception ex)
                {
                    new ToastContentBuilder()
                    .AddArgument("action", "viewConversation")
                    .AddText("FEHLER")
                    .AddText(ex.Message)
                    .Show();     //
                }
            }
        }
Esempio n. 2
0
        private static async Task <DogeCoinObj> GetDogeCoinData()
        {
            DogeCoinObj dogeCoin = null;
            await Task.Run(() =>
            {
                string Json = GetJson();
                dogeCoin    = Newtonsoft.Json.JsonConvert.DeserializeObject <DogeCoinObj>(Json);
            });

            return(dogeCoin);
        }