You can add a OnError Method at the class that contains the timers. In order to let the parent class know that an error occurs. Something like the following: At MyTimerClass public MyTimerClass(Action onError) { this.
OnError = onError; } private void ElapseEvent(object source, ElapsedEventArgs e){ try{ //read from serial port device } catch(Exception ex) // It would be better if you know the exceptions you want to handle { if(this. OnError! = null) { this.
OnError(this, ex); } } } At the parent class: var timer1= new MyTimerClass(this. OnTimerError); timer1. Execute("Device A"); _timers.
Add(timer1); var timer2= new MyTimerClass(this. OnTimerError); timer2. Execute("Device B"); _timers.
Add(timer2); public void OnTimerError(MyTimerClass timer, Exception error) { //Log the exception _timers. Remove(timer); }.
If your _timers is a static variable, then create a static event handler in the same class. When the error is thrown in a timer's ElapseEvent, call the event handler with reference to itself, and have the static event handler remove the error'ed timer from the list.
The Observer Pattern. . NET has native support for this.
You should check out the Command Pattern; sounds like it would be perfect for you.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.