468,283 Members | 2,005 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

How to properly manage state in events A and B, when event C fires

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
}
Jul 9 '08 #1
0 900

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Paul THompson | last post: by
14 posts views Thread by JPRoot | last post: by
1 post views Thread by Jack Addington | last post: by
5 posts views Thread by Sean | last post: by
7 posts views Thread by AndrewMBaldwin | last post: by
reply views Thread by bob | last post: by
1 post views Thread by Steven P | last post: by
3 posts views Thread by Leo Smith | last post: by
5 posts views Thread by Sin Jeong-hun | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.