K
kirk
I have a class with a native API inside. The API, when called,
determines the state of some entity.
I'd like to setup the interface to this class to have an event that
can be subscribed to, called OnStateChange, for example. When
subscribed to, I envisioned a timer would turn on and start calling
the API continuously every X amount of seconds and if a change
occurred, the event would fire.
My question is, what is the best way to implement code to flip the
timer for calling the API on and off? I know I can use a separate
timer that kicks in when the class is instantiated, that can
continually test the OnStateChange event for null, but this seems like
overkill. Any ideas?
Thanks.
determines the state of some entity.
I'd like to setup the interface to this class to have an event that
can be subscribed to, called OnStateChange, for example. When
subscribed to, I envisioned a timer would turn on and start calling
the API continuously every X amount of seconds and if a change
occurred, the event would fire.
My question is, what is the best way to implement code to flip the
timer for calling the API on and off? I know I can use a separate
timer that kicks in when the class is instantiated, that can
continually test the OnStateChange event for null, but this seems like
overkill. Any ideas?
Thanks.