I am creating a class (“Class B”) which is used by another class (“Class A”) which instantiates it in VB.NET 3.5.
I would like Class B to read a value assigned to one of its properties by Class A every time an event happens in Class B.
However, I would like this property value to be dynamically assigned to the property by Class A when the event is fired in Class B.
I was thinking about somehow creating a delegate function in Class A that is linked to the property in Class B so that when the event is fired in Class B it would eventually invoke the delegate in Class A so that it returns a value to Class B.
I’ve been reading around delegates (that’s how I arrived at the idea), but I am stuck on how to code this up – could someone please help with some skeleton code?
Also, I am not sure that this is the best approach for this – are there better solutions?
Thanks for your input.
I would probably isolate this from both classes a little. Maybe create a singleton that creates the value from Class A and just call that from Class B.
So
Then in Class A
In Class B