May 12, 2011
I must say personally, the WithEvents system is, shall we say, open to extreme false sense of security, so to speak. I like a lot of automation in my code, and tend to provide ways to do things manually, with a "default" behavior encoded. However, as I have just discovered, the withevents doesn't HOOK the event delegate until after creation. So even when you do New MyObject(), if an event is triggered during the Sub New() process, the delegate hasn't been assigned yet, and thus the event (which in my current situation is extremely important) never triggers. which begs the question the point of the WithEvents other than removing "AddHandler" lines from procedural code. Sure it saves on typing, due to code completion, but if that's it, that isn't much of a benefit. One would think that using the WithEvents would allow me to do:
View 2 Replies
PUblic Sub New()
Tragically, this does NOT work, which royally screws up my lazy loading techniques and other such tricks that were supposed to make my code simpler to use, and instead has made things 10 times more complex, as I have to specifically alter class initialization sequences to be outside of class instantiation. (which should be one in the same, imho).Jaeden "Sifo Dyas" al'Raec Ruiner
"Never Trust a computer. Your brain is smarter than any micro-chip."
PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.