I have a scenario that i need to implement. the scenario is below.
I have a class handler and a class Healthmonitor. every 10 seconds i have to send a msg to HealthMonitor to update a variable. in one point if it didnt send a msg in a multiple of 10 seconds HealthMonitor DO SOMETHING ELSE

How do i implement this. can someone give an idea to achieve this

appreciate it

Recommended Answers

All 5 Replies

You start a timer routine, that will fire the class event every 10 seconds, your code can interrupt this if needed, by turning the timer off then on. Your class may need a method to allow this, perhaps PerformEvent(). Then this routine can call it with something like this, MyClass.PerformEvent();

Your handler, will then keep track of the time of the last event and do what needs to be done based on comparing the time now.

hey tinstaafl

could you explain it a little bit more, i dont understand it properly
appreciate it

hi tinstaafl
i don't understand thisis the handler.class and the
so as for my scenario the event sender is the Handler.class and the event receiver is the HealthMonitor.class

i cant understand how to implement it, ?
when do i call the event receiver?

In this article,How to: Raise and Consume Events, is a full sample that shows you everything you need to know about handling events. Basically, in your sender is an event method to call the handler. You create code to fire the event, then in the handler you write code depending on the information sent from the event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.