I have two very similar classes that do essentially the same thing. The only difference is the callback handler provided to the instance of each class. Callback handlers are different, and they are accepted with different parameters. I would like to generalize most of the code from these classes to a base class. Any ideas on how to reasonably summarize the delegate code? I'm on .NET 2.0
Note: I read this very useful blog on inheritance with delegates and articles on covariance and contravariance with delegates, but I still don't see how this knowledge can be applied here.
public class A { public delegate void AHandler(string param1, string param2); public void AcceptHandler(string param3, AHandler handler); public void InvokeHandler(string forParam1, string forParam2);
EDIT: The "rest" of the code is exactly the same, except for calls to delegate methods that have different signatures. Something like that:
public void StartListening() { Timer timer = new Timer(CheckForChanges, null, 0, 1000); } private void CheckForChanges() {
source share