You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
675 B
39 lines
675 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Observer.TemperatureObserver
|
|
{
|
|
class Temperature
|
|
{
|
|
public event EventHandler Changed;
|
|
|
|
private float fahrenheit;
|
|
public float Fahrenheit
|
|
{
|
|
get { return this.fahrenheit; }
|
|
set
|
|
{
|
|
this.fahrenheit = value;
|
|
if (Changed == null)
|
|
return;
|
|
|
|
Changed(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
|
|
public void StartMeasure(int times)
|
|
{
|
|
Random r = new Random(DateTime.Now.Millisecond);
|
|
|
|
for (int i = 0; i < times; i++)
|
|
{
|
|
this.Fahrenheit = r.Next(60, 70);
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|