次のような 3 つのイベントがあります。
public static event EventHandler BelowLowLimit;
public static event EventHandler AboveHighLimit;
public static event EventHandler PercentBelowLowLimit;
protected virtual void OnThresholdReached()
{
EventHandler handler = null;
if (rs.Value < rs.LowLimit)
{
handler = BelowLowLimit;
}
else if (rs.Value > rs.UpperLimit)
{
handler = AboveHighLimit;
}
if (handler != null)
{
handler(this, new EventArgs());
}
}
次の条件に基づいてイベントを発生させる必要があります。
public long Rs
{
get { return rs.Value; }
set
{
if (rs.Value < rs.LowLimit)
{
OnThresholdReached();
}
else if (rs.Value > rs.UpperLimit)
{
OnThresholdReached();
}
else
{
this.rs.Value = value;
}
}
}
このイベントを同じメソッドに接続してイベントを発生させたいもの。これは正しい方法ですか?
それを行う方法を教えてください。