K
kirk
I have three events, using event handler methods as depicted below.
Two of those event handler methods need to reset specific data
whenever the other event left fires. I wasn't sure how to properly
implement that, is there a better way than using state management
variables for each timer as i'm doing in the outline below?
private string szProperty1 = null;
// updated by class consumer
public string Property1
{
get { return this.szProperty1; }
set { this.szProperty1 = value; }
}
// state management
private string szProperty1Last1 = null;
private string szProperty1Last2 = null;
private string szProperty1Last3 = null;
private string szProperty2 = null;
private string szProperty3 = null;
[interval: 100ms]
private void EventHandlerMethod1
{
// exit if szProperty1 == null or no event subscriptions
// if szPropertyLast1 != szProperty1, set szPropertyLast1 =
szProperty1, fire event
}
[interval: 100ms]
private void EventHandlerMethod2
{
// exit if szProperty1 == null or no event subscriptions
// if szPropertyLast2 != szProperty1, set szPropertyLast2 =
szProperty1, reset szProperty2, fire event
}
[interval: 500ms]
private void EventHandlerMethod3
{
// exit if szProperty1 == null or no event subscriptions
// if szPropertyLast3 != szProperty1, set szPropertyLast3 =
szProperty1, reset szProperty3, fire event
}
Two of those event handler methods need to reset specific data
whenever the other event left fires. I wasn't sure how to properly
implement that, is there a better way than using state management
variables for each timer as i'm doing in the outline below?
private string szProperty1 = null;
// updated by class consumer
public string Property1
{
get { return this.szProperty1; }
set { this.szProperty1 = value; }
}
// state management
private string szProperty1Last1 = null;
private string szProperty1Last2 = null;
private string szProperty1Last3 = null;
private string szProperty2 = null;
private string szProperty3 = null;
[interval: 100ms]
private void EventHandlerMethod1
{
// exit if szProperty1 == null or no event subscriptions
// if szPropertyLast1 != szProperty1, set szPropertyLast1 =
szProperty1, fire event
}
[interval: 100ms]
private void EventHandlerMethod2
{
// exit if szProperty1 == null or no event subscriptions
// if szPropertyLast2 != szProperty1, set szPropertyLast2 =
szProperty1, reset szProperty2, fire event
}
[interval: 500ms]
private void EventHandlerMethod3
{
// exit if szProperty1 == null or no event subscriptions
// if szPropertyLast3 != szProperty1, set szPropertyLast3 =
szProperty1, reset szProperty3, fire event
}