I have three events that I have created and manage with timers. Two
of the timer event handlers, the last two in the code below, need to
reset state management data, if the first event handler fires. My
question, is what I have implemented the right way to design state
management, or is there maybe a best practice to design this
differently?
private string szData1 = null;
public string Data1
{
get { return this.szData1; }
set { this.szData1 = value; }
}
private string szData2 = null;
private string szData3 = null;
// state management
private string szData1Last = null;
private string szData2Last = null;
private string szData3Last = null;
[interval: 100ms]
private void EventHandlerMethod1
{
// if szData1 != null and there are subscriptions, proceed
// if szData1Last != szData1, set szData1Last = szData1, fire event
}
[interval: 100ms]
private void EventHandlerMethod2
{
// if szData1 != null and there are subscriptions, proceed
// if szData2Last != szData1, set szData2Last = szData1, reset
szData2 value, fire event
}
[interval: 500ms]
private void EventHandlerMethod3
{
// if szData1 != null and there are subscriptions, proceed
// if szData3Last != szData1, set szData3Last = szData1, reset
szData3 value, fire event
}