Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        private void FetchWeatherAlert__Worker()
        {
            Random rnd = new Random();

            Task.Run(() =>
            {
                while (true)
                {
                    var randomNr = rnd.Next(0, 5);
                    if (randomNr == 2)
                    {
                        WeatherAlertData = new WeatherAlertData
                        {
                            IsWeatherAlert = true,
                            Severity       = "Dutch weather alert"
                        };
                    }
                    else
                    {
                        WeatherAlertData = new WeatherAlertData
                        {
                            IsWeatherAlert = false,
                            Severity       = null
                        };
                    }
                    Thread.Sleep(25000);//Dutch weather happens not too frequently atm. So look for other cities :)
                }
            });
        }
Beispiel #2
0
 public void Update(object data)
 {
     if (data is WeatherAlertData && data != null)
     {
         _weatherAlertData = (WeatherAlertData)data;
         MessageBox.Show("Extreme weather! " + _weatherAlertData.Severity);
     }
 }
Beispiel #3
0
 public WeatherAlertSubject() : base()
 {
     _weatherAlertData = new WeatherAlertData();
     FetchWeatherAlert__Worker();
 }