473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1056

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul THompson | last post by:
I have been working for some time to 1) detect tab and shift tab events 2) control the focus on the basis of these events. I have found that I can do this, but continue to have nagging problems. ...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
1
by: Jack Addington | last post by:
I have a 3rd party object that fires an itemchanged event when someone edits some data on a form. This event has a custom eventArgs that has a field called ActionCode. In the code of the event,...
5
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know...
7
by: AndrewMBaldwin | last post by:
I have a grid control (inherits from Placeholder) that has a few buttons on it. On this grid there is a filter form, which allows the user to filter/search the table for specific information. My...
0
by: bob | last post by:
Hi all, I'm having a hard time figuring out the ORDER that the events in the DataGridView control fire in, and also determining exactly WHEN each event fires. The documentation seems to have...
1
by: Steven P | last post by:
Hi, In my project I have a timer-driven state machine. The timer object are in the form. Update of controls like edit, label will be executed in some states. The state machine is in a seperate...
3
by: Leo Smith | last post by:
I have a problem with some code that fires an onclick event for an image. What I did was create a group of images to work like a button. The mouseover, mousedown, and mouseout events swap images to...
5
by: Sin Jeong-hun | last post by:
class Manager { public event ItemEventHandler ItHappened; public Manager { Item i; i.ItHappend+=new ItemEventHandler(OnItHappened); } void OnItHappened(...) {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.